coqui-ai / TTS

🐸💬 - a deep learning toolkit for Text-to-Speech, battle-tested in research and production
http://coqui.ai
Mozilla Public License 2.0
33.52k stars 4.08k forks source link

[Bug] AssertionError: [!] There are duplicate characters in the character set. {'(', '!', "'", ' ', '?', ',', ')', '-', ':', ';', '.'} #1712

Closed newgrit1004 closed 2 years ago

newgrit1004 commented 2 years ago

Describe the bug

There is a tutorial of korean version of coqui_tts.(not written by coqui-ai) tutorial link : https://colab.research.google.com/drive/1hv37sT7Pq-qKZe9Ihbbp5XZ-A9tsURli?usp=sharing Executed command !tts \ --text "$inputText" \ --model_path glowtts_korea/checkpoint.pth.tar \ --config_path glowtts_korea/config.json \ --out_path output.wav \ --vocoder_path mbmelgan_korea/checkpoint.pth.tar \ --vocoder_config_path mbmelgan_korea/config.json

Result ` > Using model: glow_tts

Setting up Audio Processor... | > sample_rate:22050 | > resample:False | > num_mels:80 | > log_func:np.log10 | > min_level_db:-100 | > frame_shift_ms:None | > frame_length_ms:None | > ref_level_db:20 | > fft_size:1024 | > power:1.5 | > preemphasis:0.0 | > griffin_lim_iters:60 | > signal_norm:True | > symmetric_norm:True | > mel_fmin:0 | > mel_fmax:None | > pitch_fmin:0.0 | > pitch_fmax:640.0 | > spec_gain:20.0 | > stft_pad_mode:reflect | > max_norm:4.0 | > clip_norm:True | > do_trim_silence:True | > trim_db:45 | > do_sound_norm:False | > do_amp_to_db_linear:True | > do_amp_to_db_mel:True | > do_rms_norm:False | > db_level:None | > stats_path:None | > base:10 | > hop_length:256 | > win_length:1024 Traceback (most recent call last): File "/usr/local/bin/tts", line 8, in sys.exit(main()) File "/usr/local/lib/python3.7/dist-packages/TTS/bin/synthesize.py", line 318, in main args.use_cuda, File "/usr/local/lib/python3.7/dist-packages/TTS/utils/synthesizer.py", line 76, in init self._load_tts(tts_checkpoint, tts_config_path, use_cuda) File "/usr/local/lib/python3.7/dist-packages/TTS/utils/synthesizer.py", line 113, in _load_tts self.tts_model = setup_tts_model(config=self.tts_config) File "/usr/local/lib/python3.7/dist-packages/TTS/tts/models/init.py", line 13, in setup_model model = MyModel.init_from_config(config, samples) File "/usr/local/lib/python3.7/dist-packages/TTS/tts/models/glow_tts.py", line 556, in init_from_config tokenizer, new_config = TTSTokenizer.init_from_config(config) File "/usr/local/lib/python3.7/dist-packages/TTS/tts/utils/text/tokenizer.py", line 174, in init_from_config characters, new_config = Graphemes().init_from_config(config) File "/usr/local/lib/python3.7/dist-packages/TTS/tts/utils/text/characters.py", line 454, in init_from_config is_sorted=config.characters["is_sorted"], File "/usr/local/lib/python3.7/dist-packages/TTS/tts/utils/text/characters.py", line 433, in init super().init(characters, punctuations, pad, eos, bos, blank, is_unique, is_sorted) File "/usr/local/lib/python3.7/dist-packages/TTS/tts/utils/text/characters.py", line 167, in init self._create_vocab() File "/usr/local/lib/python3.7/dist-packages/TTS/tts/utils/text/characters.py", line 263, in _create_vocab ), f" [!] There are duplicate characters in the character set. {duplicates}" AssertionError: [!] There are duplicate characters in the character set. {'(', '!', "'", ' ', '?', ',', ')', '-', ':', ';', '.'} /usr/local/lib/python3.7/dist-packages/librosa/core/audio.py:162: UserWarning: PySoundFile failed. Trying audioread instead. warnings.warn("PySoundFile failed. Trying audioread instead.")`

In the config.json, it contains {'(', '!', "'", ' ', '?', ',', ')', '-', ':', ';', '.'} and korean unicode characters. I saw that this error had been issued(https://github.com/coqui-ai/TTS/issues/1693), but I can't solve the error by the answer in the previous issue.(reinstall or "rm -rf ~/.local/share/tts/tts_models--multilingual--multi-dataset--your_tts/")

To Reproduce

link : https://colab.research.google.com/drive/1hv37sT7Pq-qKZe9Ihbbp5XZ-A9tsURli?usp=sharing

Run top three cells in the link

You can see this command on the link. !tts \ --text "$inputText" \ --model_path glowtts_korea/checkpoint.pth.tar \ --config_path glowtts_korea/config.json \ --out_path output.wav \ --vocoder_path mbmelgan_korea/checkpoint.pth.tar \ --vocoder_config_path mbmelgan_korea/config.json

Expected behavior

save output.wav

Logs

Traceback (most recent call last):
  File "/usr/local/bin/tts", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/TTS/bin/synthesize.py", line 318, in main
    args.use_cuda,
  File "/usr/local/lib/python3.7/dist-packages/TTS/utils/synthesizer.py", line 76, in __init__
    self._load_tts(tts_checkpoint, tts_config_path, use_cuda)
  File "/usr/local/lib/python3.7/dist-packages/TTS/utils/synthesizer.py", line 113, in _load_tts
    self.tts_model = setup_tts_model(config=self.tts_config)
  File "/usr/local/lib/python3.7/dist-packages/TTS/tts/models/__init__.py", line 13, in setup_model
    model = MyModel.init_from_config(config, samples)
  File "/usr/local/lib/python3.7/dist-packages/TTS/tts/models/glow_tts.py", line 556, in init_from_config
    tokenizer, new_config = TTSTokenizer.init_from_config(config)
  File "/usr/local/lib/python3.7/dist-packages/TTS/tts/utils/text/tokenizer.py", line 174, in init_from_config
    characters, new_config = Graphemes().init_from_config(config)
  File "/usr/local/lib/python3.7/dist-packages/TTS/tts/utils/text/characters.py", line 454, in init_from_config
    is_sorted=config.characters["is_sorted"],
  File "/usr/local/lib/python3.7/dist-packages/TTS/tts/utils/text/characters.py", line 433, in __init__
    super().__init__(characters, punctuations, pad, eos, bos, blank, is_unique, is_sorted)
  File "/usr/local/lib/python3.7/dist-packages/TTS/tts/utils/text/characters.py", line 167, in __init__
    self._create_vocab()
  File "/usr/local/lib/python3.7/dist-packages/TTS/tts/utils/text/characters.py", line 263, in _create_vocab
    ), f" [!] There are duplicate characters in the character set. {duplicates}"
AssertionError:  [!] There are duplicate characters in the character set. {'(', '!', "'", ' ', '?', ',', ')', '-', ':', ';', '.'}
/usr/local/lib/python3.7/dist-packages/librosa/core/audio.py:162: UserWarning: PySoundFile failed. Trying audioread instead.
  warnings.warn("PySoundFile failed. Trying audioread instead.")
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/librosa/core/audio.py in load(path, sr, mono, offset, duration, dtype, res_type)
    145     try:
--> 146         with sf.SoundFile(path) as sf_desc:
    147             sr_native = sf_desc.samplerate

8 frames
RuntimeError: Error opening 'output.wav': System error.

During handling of the above exception, another exception occurred:

FileNotFoundError                         Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/audioread/rawread.py in __init__(self, filename)
     60     """
     61     def __init__(self, filename):
---> 62         self._fh = open(filename, 'rb')
     63 
     64         try:

FileNotFoundError: [Errno 2] No such file or directory: 'output.wav'

Environment

{
    "CUDA": {
        "GPU": [],
        "available": false,
        "version": "11.3"
    },
    "Packages": {
        "PyTorch_debug": false,
        "PyTorch_version": "1.11.0+cu113",
        "TTS": "0.7.1",
        "numpy": "1.21.6"
    },
    "System": {
        "OS": "Linux",
        "architecture": [
            "64bit",
            ""
        ],
        "processor": "x86_64",
        "python": "3.7.13",
        "version": "#1 SMP Sun Apr 24 10:03:06 PDT 2022"
    }
}

Additional context

No response

erogol commented 2 years ago

It is not a bug. Remove duplicates in your config and it'll be fine. TTS in the tutorial might be outdated

heehminh commented 10 months ago

@newgrit1004 I want to know how you solved this error. I got the same error in the same tutorial.