prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN 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
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `TTS/utils/trainer_utils.py`
  Content:
  ```
  1 import importlib
  2 from typing import Dict
  3 
  4 import torch
  5 
  6 from TTS.utils.training import NoamLR
  7 
  8 
  9 def is_apex_available():
  10     return importlib.util.find_spec("apex") is not None
  11 
  12 
  13 def setup_torch_training_env(cudnn_enable, cudnn_benchmark):
  14     torch.backends.cudnn.enabled = cudnn_enable
  15     torch.backends.cudnn.benchmark = cudnn_benchmark
  16     torch.manual_seed(54321)
  17     use_cuda = torch.cuda.is_available()
  18     num_gpus = torch.cuda.device_count()
  19     print(" > Using CUDA: ", use_cuda)
  20     print(" > Number of GPUs: ", num_gpus)
  21     return use_cuda, num_gpus
  22 
  23 
  24 def get_scheduler(
  25     lr_scheduler: str, lr_scheduler_params: Dict, optimizer: torch.optim.Optimizer
  26 ) -> torch.optim.lr_scheduler._LRScheduler:  # pylint: disable=protected-access
  27     """Find, initialize and return a scheduler.
  28 
  29     Args:
  30         lr_scheduler (str): Scheduler name.
  31         lr_scheduler_params (Dict): Scheduler parameters.
  32         optimizer (torch.optim.Optimizer): Optimizer to pass to the scheduler.
  33 
  34     Returns:
  35         torch.optim.lr_scheduler._LRScheduler: Functional scheduler.
  36     """
  37     if lr_scheduler is None:
  38         return None
  39     if lr_scheduler.lower() == "noamlr":
  40         scheduler = NoamLR
  41     else:
  42         scheduler = getattr(torch.optim.lr_scheduler, lr_scheduler)
  43     return scheduler(optimizer, **lr_scheduler_params)
  44 
  45 
  46 def get_optimizer(
  47     optimizer_name: str, optimizer_params: dict, lr: float, model: torch.nn.Module
  48 ) -> torch.optim.Optimizer:
  49     """Find, initialize and return a optimizer.
  50 
  51     Args:
  52         optimizer_name (str): Optimizer name.
  53         optimizer_params (dict): Optimizer parameters.
  54         lr (float): Initial learning rate.
  55         model (torch.nn.Module): Model to pass to the optimizer.
  56 
  57     Returns:
  58         torch.optim.Optimizer: Functional optimizer.
  59     """
  60     if optimizer_name.lower() == "radam":
  61         module = importlib.import_module("TTS.utils.radam")
  62         optimizer = getattr(module, "RAdam")
  63     else:
  64         optimizer = getattr(torch.optim, optimizer_name)
  65     return optimizer(model.parameters(), lr=lr, **optimizer_params)
  66
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: 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 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
  
verification_info: {"golden_diff": "diff --git a/TTS/utils/trainer_utils.py b/TTS/utils/trainer_utils.py\n--- a/TTS/utils/trainer_utils.py\n+++ b/TTS/utils/trainer_utils.py\n@@ -11,11 +11,15 @@\n \n \n def setup_torch_training_env(cudnn_enable, cudnn_benchmark):\n+    num_gpus = torch.cuda.device_count()\n+    if num_gpus > 1:\n+        raise RuntimeError(\n+            f\" [!] {num_gpus} active GPUs. Define the target GPU by `CUDA_VISIBLE_DEVICES`. For multi-gpu training use `TTS/bin/distribute.py`.\"\n+        )\n     torch.backends.cudnn.enabled = cudnn_enable\n     torch.backends.cudnn.benchmark = cudnn_benchmark\n     torch.manual_seed(54321)\n     use_cuda = torch.cuda.is_available()\n-    num_gpus = torch.cuda.device_count()\n     print(\" > Using CUDA: \", use_cuda)\n     print(\" > Number of GPUs: \", num_gpus)\n     return use_cuda, num_gpus\n", "issue": "[Bug] `tts_models/en/vctk/sc-glow-tts` fails to find `speakers.json` file\n**Describe the bug**\r\n`tts_models/en/vctk/sc-glow-tts` fails to find `speakers.json` file.\r\n\r\n**To Reproduce**\r\n```\r\n$ tts --model_name tts_models/en/vctk/sc-glow-tts --text \"test\" --out_path tmp.wav\r\n > tts_models/en/vctk/sc-glow-tts is already downloaded.\r\n > vocoder_models/en/vctk/hifigan_v2 is already downloaded.\r\n > Using model: glow_tts\r\nTraceback (most recent call last):\r\n  File \"/usr/local/bin/tts\", line 8, in <module>\r\n    sys.exit(main())\r\n  File \"/usr/local/lib/python3.8/dist-packages/TTS/bin/synthesize.py\", line 226, in main\r\n    synthesizer = Synthesizer(\r\n  File \"/usr/local/lib/python3.8/dist-packages/TTS/utils/synthesizer.py\", line 73, in __init__\r\n    self._load_tts(tts_checkpoint, tts_config_path, use_cuda)\r\n  File \"/usr/local/lib/python3.8/dist-packages/TTS/utils/synthesizer.py\", line 135, in _load_tts\r\n    self.tts_model = setup_tts_model(config=self.tts_config)\r\n  File \"/usr/local/lib/python3.8/dist-packages/TTS/tts/models/__init__.py\", line 27, in setup_model\r\n    model = MyModel(config)\r\n  File \"/usr/local/lib/python3.8/dist-packages/TTS/tts/models/glow_tts.py\", line 57, in __init__\r\n    self.init_multispeaker(config)\r\n  File \"/usr/local/lib/python3.8/dist-packages/TTS/tts/models/glow_tts.py\", line 106, in init_multispeaker\r\n    self.speaker_manager = get_speaker_manager(config, data=data)\r\n  File \"/usr/local/lib/python3.8/dist-packages/TTS/tts/utils/speakers.py\", line 354, in get_speaker_manager\r\n    speaker_manager.set_d_vectors_from_file(c.d_vector_file)\r\n  File \"/usr/local/lib/python3.8/dist-packages/TTS/tts/utils/speakers.py\", line 161, in set_d_vectors_from_file\r\n    self.d_vectors = self._load_json(file_path)\r\n  File \"/usr/local/lib/python3.8/dist-packages/TTS/tts/utils/speakers.py\", line 85, in _load_json\r\n    with open(json_file_path) as f:\r\nFileNotFoundError: [Errno 2] No such file or directory: '/home/erogol/.local/share/tts/tts_models--en--vctk--sc-glow-tts/speakers.json'\r\n```\r\n\r\nThe 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):\r\n```\r\n\"d_vector_file\": \"/home/erogol/.local/share/tts/tts_models--en--vctk--sc-glow-tts/speakers.json\"\r\n```\r\n\r\nIf 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.\r\n\r\n**Environment (please complete the following information):**\r\nUsing the following Dockerfile:\r\n```\r\nFROM ubuntu:focal\r\nENV DEBIAN_FRONTEND=noninteractive \r\nRUN apt update && \\\r\n    apt install -y ca-certificates && update-ca-certificates && \\\r\n    apt install -y espeak-ng git libsndfile1 python3 python3-pip\r\nRUN python3 -m pip install git+git://github.com/coqui-ai/TTS.git@v0.1.0\r\n```\r\n\n", "before_files": [{"content": "import importlib\nfrom typing import Dict\n\nimport torch\n\nfrom TTS.utils.training import NoamLR\n\n\ndef is_apex_available():\n    return importlib.util.find_spec(\"apex\") is not None\n\n\ndef setup_torch_training_env(cudnn_enable, cudnn_benchmark):\n    torch.backends.cudnn.enabled = cudnn_enable\n    torch.backends.cudnn.benchmark = cudnn_benchmark\n    torch.manual_seed(54321)\n    use_cuda = torch.cuda.is_available()\n    num_gpus = torch.cuda.device_count()\n    print(\" > Using CUDA: \", use_cuda)\n    print(\" > Number of GPUs: \", num_gpus)\n    return use_cuda, num_gpus\n\n\ndef get_scheduler(\n    lr_scheduler: str, lr_scheduler_params: Dict, optimizer: torch.optim.Optimizer\n) -> torch.optim.lr_scheduler._LRScheduler:  # pylint: disable=protected-access\n    \"\"\"Find, initialize and return a scheduler.\n\n    Args:\n        lr_scheduler (str): Scheduler name.\n        lr_scheduler_params (Dict): Scheduler parameters.\n        optimizer (torch.optim.Optimizer): Optimizer to pass to the scheduler.\n\n    Returns:\n        torch.optim.lr_scheduler._LRScheduler: Functional scheduler.\n    \"\"\"\n    if lr_scheduler is None:\n        return None\n    if lr_scheduler.lower() == \"noamlr\":\n        scheduler = NoamLR\n    else:\n        scheduler = getattr(torch.optim.lr_scheduler, lr_scheduler)\n    return scheduler(optimizer, **lr_scheduler_params)\n\n\ndef get_optimizer(\n    optimizer_name: str, optimizer_params: dict, lr: float, model: torch.nn.Module\n) -> torch.optim.Optimizer:\n    \"\"\"Find, initialize and return a optimizer.\n\n    Args:\n        optimizer_name (str): Optimizer name.\n        optimizer_params (dict): Optimizer parameters.\n        lr (float): Initial learning rate.\n        model (torch.nn.Module): Model to pass to the optimizer.\n\n    Returns:\n        torch.optim.Optimizer: Functional optimizer.\n    \"\"\"\n    if optimizer_name.lower() == \"radam\":\n        module = importlib.import_module(\"TTS.utils.radam\")\n        optimizer = getattr(module, \"RAdam\")\n    else:\n        optimizer = getattr(torch.optim, optimizer_name)\n    return optimizer(model.parameters(), lr=lr, **optimizer_params)\n", "path": "TTS/utils/trainer_utils.py"}], "after_files": [{"content": "import importlib\nfrom typing import Dict\n\nimport torch\n\nfrom TTS.utils.training import NoamLR\n\n\ndef is_apex_available():\n    return importlib.util.find_spec(\"apex\") is not None\n\n\ndef setup_torch_training_env(cudnn_enable, cudnn_benchmark):\n    num_gpus = torch.cuda.device_count()\n    if num_gpus > 1:\n        raise RuntimeError(\n            f\" [!] {num_gpus} active GPUs. Define the target GPU by `CUDA_VISIBLE_DEVICES`. For multi-gpu training use `TTS/bin/distribute.py`.\"\n        )\n    torch.backends.cudnn.enabled = cudnn_enable\n    torch.backends.cudnn.benchmark = cudnn_benchmark\n    torch.manual_seed(54321)\n    use_cuda = torch.cuda.is_available()\n    print(\" > Using CUDA: \", use_cuda)\n    print(\" > Number of GPUs: \", num_gpus)\n    return use_cuda, num_gpus\n\n\ndef get_scheduler(\n    lr_scheduler: str, lr_scheduler_params: Dict, optimizer: torch.optim.Optimizer\n) -> torch.optim.lr_scheduler._LRScheduler:  # pylint: disable=protected-access\n    \"\"\"Find, initialize and return a scheduler.\n\n    Args:\n        lr_scheduler (str): Scheduler name.\n        lr_scheduler_params (Dict): Scheduler parameters.\n        optimizer (torch.optim.Optimizer): Optimizer to pass to the scheduler.\n\n    Returns:\n        torch.optim.lr_scheduler._LRScheduler: Functional scheduler.\n    \"\"\"\n    if lr_scheduler is None:\n        return None\n    if lr_scheduler.lower() == \"noamlr\":\n        scheduler = NoamLR\n    else:\n        scheduler = getattr(torch.optim.lr_scheduler, lr_scheduler)\n    return scheduler(optimizer, **lr_scheduler_params)\n\n\ndef get_optimizer(\n    optimizer_name: str, optimizer_params: dict, lr: float, model: torch.nn.Module\n) -> torch.optim.Optimizer:\n    \"\"\"Find, initialize and return a optimizer.\n\n    Args:\n        optimizer_name (str): Optimizer name.\n        optimizer_params (dict): Optimizer parameters.\n        lr (float): Initial learning rate.\n        model (torch.nn.Module): Model to pass to the optimizer.\n\n    Returns:\n        torch.optim.Optimizer: Functional optimizer.\n    \"\"\"\n    if optimizer_name.lower() == \"radam\":\n        module = importlib.import_module(\"TTS.utils.radam\")\n        optimizer = getattr(module, \"RAdam\")\n    else:\n        optimizer = getattr(torch.optim, optimizer_name)\n    return optimizer(model.parameters(), lr=lr, **optimizer_params)\n", "path": "TTS/utils/trainer_utils.py"}]}