[Python] AttributeError: module 'TTS.tts.datasets' has no attribute '' when generating...

Discussão em 'Python' iniciado por Stack, Março 4, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to create a tts model with my own voice using Mozilla TTS. I'm following this stackoverflow post with the only difference being that my OS is Windows. In the second last step it says to prepare the scale_stats.npy. For that you need to run a command that specifies an output file and your config.json. I have the config setup using a previous step. When I run this command, it gives me this error:

    File "C:\Python311\Lib\site-packages\TTS\bin\compute_statistics.py", line 96, in <module>
    main()
    File "C:\Python311\Lib\site-packages\TTS\bin\compute_statistics.py", line 44, in main
    dataset_items = load_tts_samples(CONFIG.datasets)[0] # take only train data
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Python311\Lib\site-packages\TTS\tts\datasets\__init__.py", line 118, in load_tts_samples
    formatter = _get_formatter_by_name(formatter_name)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Python311\Lib\site-packages\TTS\tts\datasets\__init__.py", line 166, in _get_formatter_by_name
    return getattr(thismodule, name.lower())
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AttributeError: module 'TTS.tts.datasets' has no attribute ''


    I have no idea what that means, since i've specified a dataset in the config.json and I haven't found anything online. This is my config.json:

    {
    "model": "Tacotron2",
    "run_name": "TTS",
    "run_description": "TTS model with my voice",

    "audio":{
    "fft_size": 1024,
    "win_length": 1024,
    "hop_length": 256,
    "frame_length_ms": null,
    "frame_shift_ms": null,

    "sample_rate": 22050,
    "preemphasis": 0.0,
    "ref_level_db": 20,

    "do_trim_silence": true,
    "trim_db": 60,
    "power": 1.5,
    "griffin_lim_iters": 60,

    "num_mels": 80,
    "mel_fmin": 50.0,
    "mel_fmax": 7600.0,
    "spec_gain": 1,

    "signal_norm": true,
    "min_level_db": -100,
    "symmetric_norm": true,
    "max_norm": 4.0,
    "clip_norm": true,
    "stats_path": "scale_stats.npy"
    },


    "characters":{
    "pad": "_",
    "eos": "~",
    "bos": "^",
    "characters": "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!(),-.:;? ",
    "punctuations":"!'(),-.:;? ",
    "phonemes":"iyɨʉɯuɪʏʊeøɘəɵɤoɛœɜɞʌɔæɐaɶɑɒᵻʘɓǀɗǃʄǂɠǁʛpbtdʈɖcɟkɡqɢʔɴŋɲɳnɱmʙrʀⱱɾɽɸβfvθðszʃʒʂʐçʝxɣχʁħʕhɦɬɮʋɹɻjɰlɭʎʟˈˌːˑʍwɥʜʢʡɕʑɺɧɚ˞ɫäöüß"
    },

    "distributed":{
    "backend": "nccl",
    "url": "tcp:\/\/localhost:54321"
    },

    "reinit_layers": [],
    "batch_size": 32,
    "eval_batch_size":16,
    "r": 7,
    "gradual_training": [[0, 7, 64], [1, 5, 64], [50000, 3, 32], [130000, 2, 32], [290000, 1, 32]],
    "mixed_precision": true,

    "loss_masking": true,
    "decoder_loss_alpha": 0.5,
    "postnet_loss_alpha": 0.25,
    "postnet_diff_spec_alpha": 0.25,
    "decoder_diff_spec_alpha": 0.25,
    "decoder_ssim_alpha": 0.5,
    "postnet_ssim_alpha": 0.25,
    "ga_alpha": 5.0,
    "stopnet_pos_weight": 15.0,

    "run_eval": true,
    "test_delay_epochs": 10,
    "test_sentences_file": null,
    "noam_schedule": false,
    "grad_clip": 1.0,
    "epochs": 1000,
    "lr": 0.0001,
    "wd": 0.000001,
    "warmup_steps": 4000,
    "seq_len_norm": false,
    "memory_size": -1,
    "prenet_type": "original",
    "prenet_dropout": false,

    "attention_type": "original",
    "attention_heads": 4,
    "attention_norm": "sigmoid",
    "windowing": false,
    "use_forward_attn": false,
    "forward_attn_mask": false,
    "transition_agent": false,
    "location_attn": true,
    "bidirectional_decoder": false,
    "double_decoder_consistency": true,
    "ddc_r": 7,

    "stopnet": true,
    "separate_stopnet": true,
    "print_step": 25,
    "tb_plot_step": 100,
    "print_eval": false,
    "save_step": 10000,
    "checkpoint": true,
    "tb_model_param_stats": false,

    "text_cleaner": "phoneme_cleaners",
    "enable_eos_bos_chars": false,
    "num_loader_workers": 4,
    "num_val_loader_workers": 4,
    "batch_group_size": 4,
    "min_seq_len": 6,
    "max_seq_len": 153,
    "compute_input_seq_cache": false,
    "use_noise_augment": true,

    "output_path": "model",

    "phoneme_cache_path": "cache",
    "use_phonemes": true,
    "phoneme_language": "de-de",
    "use_speaker_embedding": false,
    "use_gst": false,
    "use_external_speaker_embedding_file": false,
    "external_speaker_embedding_file": "../../speakers-vctk-en.json",
    "gst": {
    "gst_style_input": null,
    "gst_embedding_dim": 512,
    "gst_num_heads": 4,
    "gst_style_tokens": 10,
    "gst_use_speaker_embedding": false
    },

    "datasets":
    [
    {
    "name": "ljspeech",
    "path": "/dataset",
    "meta_file_train": "/dataset/metadata.csv",
    "meta_file_val": null
    }
    ]
    }


    The Dataset is prepared too, with the .csv and the .wav files. I've checked all the paths that I changed in the config file. Do you have any idea what this error message, espacially the AttributeError: module 'TTS.tts.datasets' has no attribute '' means? For me it looks like there is another config that needs to be edited or where somehow an attribute exists that is just called ''. Any help would be really appreciated!

    Continue reading...

Compartilhe esta Página