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
35.48k stars 4.33k forks source link

[Bug] When running pip version of TTS, "Unable to init server: Could not connect: Connection refused" and "No such file or directory: '/home/ubuntu/ProjectsMac" errors occur #730

Closed kyutums closed 3 years ago

kyutums commented 3 years ago

Describe the bug Trying out TTS by typing tts --text "Text for TTS" --model_name "tts_models/en/vctk/vits" --out_path /home/user/output.wav resulted in odd errors. The one with the folder /home/ubuntu/ProjectsMac was very odd as I did not pass any variables that are even remotely related to this.

The complete results of the previous command are:

Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused

(tts:14371): Gdk-CRITICAL **: 21:51:00.534: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
 > tts_models/en/vctk/vits is already downloaded.
 > Using model: vits
Traceback (most recent call last):
  File "/home/user/.local/bin/tts", line 8, in <module>
    sys.exit(main())
  File "/home/user/.local/lib/python3.8/site-packages/TTS/bin/synthesize.py", line 226, in main
    synthesizer = Synthesizer(
  File "/home/user/.local/lib/python3.8/site-packages/TTS/utils/synthesizer.py", line 72, in __init__
    self._load_tts(tts_checkpoint, tts_config_path, use_cuda)
  File "/home/user/.local/lib/python3.8/site-packages/TTS/utils/synthesizer.py", line 147, in _load_tts
    self.tts_model = setup_tts_model(config=self.tts_config)
  File "/home/user/.local/lib/python3.8/site-packages/TTS/tts/models/__init__.py", line 30, in setup_model
    model = MyModel(config)
  File "/home/user/.local/lib/python3.8/site-packages/TTS/tts/models/vits.py", line 265, in __init__
    self.init_multispeaker(config)
  File "/home/user/.local/lib/python3.8/site-packages/TTS/tts/models/vits.py", line 352, in init_multispeaker
    self.speaker_manager = get_speaker_manager(config, data=data)
  File "/home/user/.local/lib/python3.8/site-packages/TTS/tts/utils/speakers.py", line 367, in get_speaker_manager
    speaker_manager.set_speaker_ids_from_file(c.speakers_file)
  File "/home/user/.local/lib/python3.8/site-packages/TTS/tts/utils/speakers.py", line 140, in set_speaker_ids_from_file
    self.speaker_ids = self._load_json(file_path)
  File "/home/user/.local/lib/python3.8/site-packages/TTS/tts/utils/speakers.py", line 88, in _load_json
    with fsspec.open(json_file_path, "r") as f:
  File "/home/user/.local/lib/python3.8/site-packages/fsspec/core.py", line 102, in __enter__
    f = self.fs.open(self.path, mode=mode)
  File "/home/user/.local/lib/python3.8/site-packages/fsspec/spec.py", line 976, in open
    f = self._open(
  File "/home/user/.local/lib/python3.8/site-packages/fsspec/implementations/local.py", line 145, in _open
    return LocalFileOpener(path, mode, fs=self, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/fsspec/implementations/local.py", line 236, in __init__
    self._open()
  File "/home/user/.local/lib/python3.8/site-packages/fsspec/implementations/local.py", line 241, in _open
    self.f = open(self.path, mode=self.mode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/ubuntu/ProjectsMac/TTS/tts_models--en--vctk--vits/speaker_ids.json'

To Reproduce Steps to reproduce the behavior:

  1. install TTS via pip as per instructions. (pip install TTS)
  2. Run the following command 'tts --text "Text for TTS" --model_name "tts_models/en/vctk/vits" --out_path /home/user/output.wav'
  3. See error listed above

Expected behavior I expected TTS to create a .wav file with the audio noting "Text for TTS"

Environment (please complete the following information):

Additional context tts-server worked and gave a working test site, but tts raw didn't (errors above)

erogol commented 3 years ago

I think @Edresson is on it.

You need to edit the path of the file in config.json based on your system. Currently, it is not done automatically.

kyutums commented 3 years ago

Is this stored in the user directory which installed it via pip?

nitinthewiz commented 3 years ago

I second this... Seeing the exact same error as above -

FileNotFoundError: [Errno 2] No such file or directory: '/home/ubuntu/ProjectsMac/TTS/tts_models--en--vctk--vits/speaker_ids.json'

Rather funny because I'm on a Mac and thought I did something silly. But this seems to be some dev's local environment being posted online.

My current solution is to give it the model_path folder for vctk-vits and that seems to work.

nitinthewiz commented 3 years ago

Found the issue here - https://github.com/coqui-ai/TTS/blob/c3082267073ed45b69993aa83437958b1c42615f/TTS/.models.json#L81

The referenced file - https://github.com/coqui-ai/TTS/releases/download/v0.2.0/tts_models--en--vctk--vits.zip

has the following in the config.json file on line 170 -

"speakers_file": "/home/ubuntu/ProjectsMac/TTS/tts_models--en--vctk--vits/speaker_ids.json",

I also noticed a few more absolute paths in other models.

In tts_models--en--vctk--sc-glow-tts -

"d_vector_file": "/home/erogol/.local/share/tts/tts_models--en--vctk--sc-glow-tts/speakers.json",

In ljspeech-dcattn-April-05-2021_01+52PM-0947822 -

"output_path": "/home/ubuntu/MyDrive/Trainings/sam/",
"phoneme_cache_path": "/home/ubuntu/en-us-phonemes/",
"datasets": [
        {
            "meta_file_train": "recording_script.xml",
            "meta_file_val": null,
            "name": "sam_accenture",
            "path": "/home/ubuntu/MyDrive/Datasets/non-binary-voice-files/"
        }
    ]

The output_path gets overridden easily, but speakers_file does not and I haven't tested it but possibly neither does the d_vector_file, so the first two models would fail.

I think these are being trained locally and uploaded manually to the release. So I don't see how I can help in fixing these. Could the devs or release lead please look into fixing these absolute paths?

Thanks!