Repository: coqui-ai/TTS

Issue:
[Bug] `tts_models/en/vctk/sc-glow-tts` fails to find `speakers.json` file
**Describe the bug**
`tts_models/en/vctk/sc-glow-tts` fails to find `speakers.json` file.

**To Reproduce**
```
$ tts --model_name tts_models/en/vctk/sc-glow-tts --text "test" --out_path tmp.wav
 > tts_models/en/vctk/sc-glow-tts is already downloaded.
 > vocoder_models/en/vctk/hifigan_v2 is already downloaded.
 > Using model: glow_tts
Traceback (most recent call last):
  File "/usr/local/bin/tts", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/TTS/bin/synthesize.py", line 226, in main
    synthesizer = Synthesizer(
  File "/usr/local/lib/python3.8/dist-packages/TTS/utils/synthesizer.py", line 73, in __init__
    self._load_tts(tts_checkpoint, tts_config_path, use_cuda)
  File "/usr/local/lib/python3.8/dist-packages/TTS/utils/synthesizer.py", line 135, in _load_tts
    self.tts_model = setup_tts_model(config=self.tts_config)
  File "/usr/local/lib/python3.8/dist-packages/TTS/tts/models/__init__.py", line 27, in setup_model
    model = MyModel(config)
  File "/usr/local/lib/python3.8/dist-packages/TTS/tts/models/glow_tts.py", line 57, in __init__
    self.init_multispeaker(config)
  File "/usr/local/lib/python3.8/dist-packages/TTS/tts/models/glow_tts.py", line 106, in init_multispeaker
    self.speaker_manager = get_speaker_manager(config, data=data)
  File "/usr/local/lib/python3.8/dist-packages/TTS/tts/utils/speakers.py", line 354, in get_speaker_manager
    speaker_manager.set_d_vectors_from_file(c.d_vector_file)
  File "/usr/local/lib/python3.8/dist-packages/TTS/tts/utils/speakers.py", line 161, in set_d_vectors_from_file
    self.d_vectors = self._load_json(file_path)
  File "/usr/local/lib/python3.8/dist-packages/TTS/tts/utils/speakers.py", line 85, in _load_json
    with open(json_file_path) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/erogol/.local/share/tts/tts_models--en--vctk--sc-glow-tts/speakers.json'
```

The problem appears to be on line 143 of the `config.json` within the [model ZIP file](https://github.com/coqui-ai/TTS/releases/download/v0.1.0/tts_models--en--vctk--sc-glow-tts.zip):
```
"d_vector_file": "/home/erogol/.local/share/tts/tts_models--en--vctk--sc-glow-tts/speakers.json"
```

If I change that line in `~/.local/share/tts/tts_models--en--vctk--sc-glow-tts/config.json` to my own local path, then it works. I haven't been able to figure out how to make a relative path work.

**Environment (please complete the following information):**
Using the following Dockerfile:
```
FROM ubuntu:focal
ENV DEBIAN_FRONTEND=noninteractive 
RUN apt update && \
    apt install -y ca-certificates && update-ca-certificates && \
    apt install -y espeak-ng git libsndfile1 python3 python3-pip
RUN python3 -m pip install git+git://github.com/coqui-ai/TTS.git@v0.1.0
```



Discussion:

Resolving patch:
diff --git a/TTS/utils/trainer_utils.py b/TTS/utils/trainer_utils.py
--- a/TTS/utils/trainer_utils.py
+++ b/TTS/utils/trainer_utils.py
@@ -11,11 +11,15 @@ def is_apex_available():
 
 
 def setup_torch_training_env(cudnn_enable, cudnn_benchmark):
+    num_gpus = torch.cuda.device_count()
+    if num_gpus > 1:
+        raise RuntimeError(
+            f" [!] {num_gpus} active GPUs. Define the target GPU by `CUDA_VISIBLE_DEVICES`. For multi-gpu training use `TTS/bin/distribute.py`."
+        )
     torch.backends.cudnn.enabled = cudnn_enable
     torch.backends.cudnn.benchmark = cudnn_benchmark
     torch.manual_seed(54321)
     use_cuda = torch.cuda.is_available()
-    num_gpus = torch.cuda.device_count()
     print(" > Using CUDA: ", use_cuda)
     print(" > Number of GPUs: ", num_gpus)
     return use_cuda, num_gpus


Test patch:
diff --git a/tests/inference_tests/test_synthesize.py b/tests/inference_tests/test_synthesize.py
--- a/tests/inference_tests/test_synthesize.py
+++ b/tests/inference_tests/test_synthesize.py
@@ -10,19 +10,19 @@ def test_synthesize():
 
     # single speaker model
     run_cli(f'tts --text "This is an example." --out_path "{output_path}"')
-    # run_cli(
-    #     "tts --model_name tts_models/en/ljspeech/speedy-speech-wn "
-    #     f'--text "This is an example." --out_path "{output_path}"'
-    # )
-    # run_cli(
-    #     "tts --model_name tts_models/en/ljspeech/speedy-speech-wn  "
-    #     "--vocoder_name vocoder_models/en/ljspeech/multiband-melgan "
-    #     f'--text "This is an example." --out_path "{output_path}"'
-    # )
+    run_cli(
+        "tts --model_name tts_models/en/ljspeech/speedy-speech-wn "
+        f'--text "This is an example." --out_path "{output_path}"'
+    )
+    run_cli(
+        "tts --model_name tts_models/en/ljspeech/speedy-speech-wn  "
+        "--vocoder_name vocoder_models/en/ljspeech/multiband-melgan "
+        f'--text "This is an example." --out_path "{output_path}"'
+    )
 
-    # # multi-speaker model
-    # run_cli("tts --model_name tts_models/en/vctk/sc-glow-tts --list_speaker_idxs")
-    # run_cli(
-    #     f'tts --model_name tts_models/en/vctk/sc-glow-tts --speaker_idx "p304" '
-    #     f'--text "This is an example." --out_path "{output_path}"'
-    # )
+    # multi-speaker model
+    run_cli("tts --model_name tts_models/en/vctk/sc-glow-tts --list_speaker_idxs")
+    run_cli(
+        f'tts --model_name tts_models/en/vctk/sc-glow-tts --speaker_idx "p304" '
+        f'--text "This is an example." --out_path "{output_path}"'
+    )