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.44k stars 4.07k forks source link

[Bug] ValueError: Model file not found in the output path #2212

Closed agilebean closed 1 year ago

agilebean commented 1 year ago

Describe the bug

Describe the bug

On an Apple Silicon M1 with MacOS Ventura, I could replicate the following for

After the installation process (see To Reproduce section), the following commands work:

tts --model_info_by_name tts_models/en/ljspeech/glow-tts
>>
> model type : tts_models
> language supported : en
> dataset used : ljspeech
> model name : glow-tts
> description :
> default_vocoder : vocoder_models/en/ljspeech/multiband-melgan

However, the following command does not work:

tts --text "Text for TTS" --model_name tts_models/en/ljspeech/glow-tts --out_path output/speech.wav

It throws this error:

 File "/Users/chaehan/TTS/TTS/utils/manage.py", line 268, in _find_files
    raise ValueError(" [!] Model file not found in the output path")

To Reproduce

Installed TTS repo with mamba:

# create mambaforge environment
mamba create -n tts
mamba activate tts

# install arm64 dependency before installing mecab-python3
arch -arm64e /opt/homebrew/bin/brew install mecab

# install dependency python
mamba install python=3.10

# install repo packages
cd tts
pip install -e .[all]

Expected behavior

No response

Logs

tts --text "Text for TTS" --model_name tts_models/en/ljspeech/glow-tts --out_path output/speech.wav

 > tts_models/en/ljspeech/glow-tts is already downloaded.
 > vocoder_models/en/ljspeech/multiband-melgan is already downloaded.
Traceback (most recent call last):
  File "/Users/chaehan/mambaforge/envs/tts/bin/tts", line 8, in <module>
    sys.exit(main())
  File "/Users/chaehan/TTS/TTS/bin/synthesize.py", line 298, in main
    vocoder_path, vocoder_config_path, _ = manager.download_model(args.vocoder_name)
  File "/Users/chaehan/TTS/TTS/utils/manage.py", line 245, in download_model
    output_model_path, output_config_path = self._find_files(output_path)
  File "/Users/chaehan/TTS/TTS/utils/manage.py", line 268, in _find_files
    raise ValueError(" [!] Model file not found in the output path")

Environment

- TTS: 0.9.0
- Python: 3.10
- OS: MacOS Ventura
- mecab-python3 1.0.5

Additional context

No response

erogol commented 1 year ago

Can't reproduce.

If you have stopped downloading before, the model folder is created but the folder is empty so TTS thinks there is the model. You need to remove that folder manually from ~/.local/shared/tts

agilebean commented 1 year ago

Thanks, however I found that the ~/.local/shared/tts folder is empty. As this issue is relevant for Apple Silicon users, they might find it useful if you reopen this issue.

The error persists but differs from model to model. With --model_name tts_models/en/ek1/tacotron2, the following error is thrown:

Traceback (most recent call last):
  File "/Users/chaehan/mambaforge/envs/tts/bin/tts", line 8, in <module>
    sys.exit(main())
  File "/Users/chaehan/TTS/TTS/bin/synthesize.py", line 370, in main
    synthesizer.save_wav(wav, args.out_path)
  File "/Users/chaehan/TTS/TTS/utils/synthesizer.py", line 172, in save_wav
    self.tts_model.ap.save_wav(wav, path, self.output_sample_rate)
  File "/Users/chaehan/TTS/TTS/utils/audio/processor.py", line 707, in save_wav
    scipy.io.wavfile.write(path, sr if sr else self.sample_rate, wav_norm.astype(np.int16))
  File "/Users/chaehan/mambaforge/envs/tts/lib/python3.10/site-packages/scipy/io/wavfile.py", line 766, in write
    fid = open(filename, 'wb')
FileNotFoundError: [Errno 2] No such file or directory: 'output/speech.wav'
jevenzh commented 1 year ago

In my case, on Ubuntu, deleting everything under ~/.local/share/tts solved my problem.

mweitzel2005 commented 1 year ago

I've got the same error on my MacBook. Looking at the manage.py file I suspect that an unfinished model download can create this situation.

Lines 239-240 of manage.py:

        if os.path.exists(output_path):
              print(f" > {model_name} is already downloaded.")

When a model download fails or gets manually interupted, the if statement will still evaluate to True since the path would have been created for the download and the script will erroneously expect that the model file is already downloaded which may not be the case.

mweitzel2005 commented 1 year ago

FWIW, the folder to delete under mac OS is: /Users/<username>/Library/Application Support/tts

NB: Don't forget to enclose the path with quotes (') when trying to delete it due to the spaces in the fodler path.

mweitzel2005 commented 1 year ago

@erogol should be relatively easy to reproduce by pressing Ctrl+C during the model download (probably should be the same on other platforms as well):

> Downloading model to /Users/<username>/Library/Application Support/tts/tts_models--multilingual--multi-dataset--your_tts
  4%|██▎                                                      | 17.7M/425M [01:53<28:41, 237kiB/s]
christiandarkin commented 2 weeks ago

it happens under windows- but there is no /.local/shared/tts folder, and even deleting the entire venv and uninstalling tts does not fix it.

eginhard commented 2 weeks ago

@christiandarkin On Windows the default folder where models are stored is something like C:\Users\...\AppData\Local\tts\