Repository: coqui-ai/TTS

Issue:
[Bug] KeyError with Tortoise and custom speaker directory
### Describe the bug

The docs do not have proper documentation on how to run Tortoise. They immediately throw a KeyError upon attempted use.

### To Reproduce

1. Download the following file and unzip it somewhere (contains sample files): 
[jfk.zip](https://github.com/coqui-ai/TTS/files/11974023/jfk.zip)

2. Run the following command or execute the following code (both exhibit the same result), replacing your voice directory as required.
```
tts --model_name  tts_models/en/multi-dataset/tortoise-v2 \
  --text "This is an example." \
  --out_path "output.wav" \
  --voice_dir /home/zero/data/audio-samples/ \
  --speaker_idx "jfk" \
  --progress_bar True
```
```py
from TTS.api import TTS

# Load the model
tortoise = TTS("tts_models/en/multi-dataset/tortoise-v2")
print(" - Loaded `tortoise`")

speaker = "jfk"
src_dir = "/home/zero/data/audio-samples/"
output_base = "/home/zero/data/audio-samples/{}/quick-brown-fox-{}.wav"
text_sample = "The quick brown fox jumps over the lazy dog."

tortoise.tts_to_file(text=text_sample,
                     file_path=output_base.format(speaker, "tortoise-ultra_fast"),
                     voice_dir=src_dir,
                     speaker=speaker,
                     preset="ultra_fast")
```

### Expected behavior

No KeyError exception.

### Logs

```
zero@zero-desktop ~/PycharmProjects/scripty-tts-server > tts --model_name  tts_models/en/multi-dataset/tortoise-v2 \
                                                             --text "This is an example." \
                                                             --out_path "output.wav" \
                                                             --voice_dir /home/zero/data/audio-samples/ \
                                                             --speaker_idx "jfk" \
                                                             --progress_bar True
 > tts_models/en/multi-dataset/tortoise-v2 is already downloaded.
 > Model's license - apache 2.0
 > Check https://choosealicense.com/licenses/apache-2.0/ for more info.
 > Using model: tortoise
 > Text: This is an example.
 > Text splitted to sentences.
['This is an example.']
Traceback (most recent call last):
  File "/home/zero/PycharmProjects/scripty-tts-server/venv/bin/tts", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/zero/PycharmProjects/scripty-tts-server/venv/lib/python3.11/site-packages/TTS/bin/synthesize.py", line 447, in main
    wav = synthesizer.tts(args.text, speaker_name=args.speaker_idx)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zero/PycharmProjects/scripty-tts-server/venv/lib/python3.11/site-packages/TTS/utils/synthesizer.py", line 365, in tts
    outputs = self.tts_model.synthesize(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zero/PycharmProjects/scripty-tts-server/venv/lib/python3.11/site-packages/TTS/tts/models/tortoise.py", line 520, in synthesize
    voice_samples, conditioning_latents = load_voice(speaker_id)
                                          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zero/PycharmProjects/scripty-tts-server/venv/lib/python3.11/site-packages/TTS/tts/layers/tortoise/audio_utils.py", line 122, in load_voice
    paths = voices[voice]
            ~~~~~~^^^^^^^
KeyError: 'jfk'
```


### Environment

```shell
{
    "CUDA": {
        "GPU": [],
        "available": false,
        "version": null
    },
    "Packages": {
        "PyTorch_debug": false,
        "PyTorch_version": "2.0.1+cpu",
        "TTS": "0.15.5",
        "numpy": "1.24.1"
    },
    "System": {
        "OS": "Linux",
        "architecture": [
            "64bit",
            "ELF"
        ],
        "processor": "",
        "python": "3.11.3",
        "version": "#1 SMP PREEMPT_DYNAMIC Sat, 01 Jul 2023 16:17:21 +0000"
    }
}
```


### Additional context

_No response_


Discussion:
@tazz4843 does your voice dir have a folder called jfk ?
It does

Resolving patch:
diff --git a/TTS/tts/models/tortoise.py b/TTS/tts/models/tortoise.py
--- a/TTS/tts/models/tortoise.py
+++ b/TTS/tts/models/tortoise.py
@@ -497,14 +497,14 @@ def get_random_conditioning_latents(self):
         with torch.no_grad():
             return self.rlg_auto(torch.tensor([0.0])), self.rlg_diffusion(torch.tensor([0.0]))
 
-    def synthesize(self, text, config, speaker_id="random", extra_voice_dirs=None, **kwargs):
+    def synthesize(self, text, config, speaker_id="random", voice_dirs=None, **kwargs):
         """Synthesize speech with the given input text.
 
         Args:
             text (str): Input text.
             config (TortoiseConfig): Config with inference parameters.
             speaker_id (str): One of the available speaker names. If `random`, it generates a random speaker.
-            extra_voice_dirs (List[str]): List of paths that host reference audio files for speakers. Defaults to None.
+            voice_dirs (List[str]): List of paths that host reference audio files for speakers. Defaults to None.
             **kwargs: Inference settings. See `inference()`.
 
         Returns:
@@ -513,9 +513,9 @@ def synthesize(self, text, config, speaker_id="random", extra_voice_dirs=None, *
             as latents used at inference.
 
         """
-        if extra_voice_dirs is not None:
-            extra_voice_dirs = [extra_voice_dirs]
-            voice_samples, conditioning_latents = load_voice(speaker_id, extra_voice_dirs)
+        if voice_dirs is not None:
+            voice_dirs = [voice_dirs]
+            voice_samples, conditioning_latents = load_voice(speaker_id, voice_dirs)
         else:
             voice_samples, conditioning_latents = load_voice(speaker_id)
 


Test patch: