Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] KeyError with Tortoise and custom speaker directory #2745

Closed
tazz4843 opened this issue Jul 7, 2023 · 5 comments
Closed

[Bug] KeyError with Tortoise and custom speaker directory #2745

tazz4843 opened this issue Jul 7, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@tazz4843
Copy link

tazz4843 commented Jul 7, 2023

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

  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
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

{
    "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

@tazz4843 tazz4843 added the bug Something isn't working label Jul 7, 2023
@manmay-nakhashi
Copy link
Collaborator

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

@tazz4843
Copy link
Author

tazz4843 commented Jul 7, 2023

It does

erogol added a commit that referenced this issue Jul 7, 2023
@erogol
Copy link
Member

erogol commented Jul 7, 2023

@tazz4843 can you try #2748

@tazz4843
Copy link
Author

tazz4843 commented Jul 7, 2023

Seems to solve this issue, but I get a different, unrelated error now. I'll open a new issue for it.

@fyunusa
Copy link

fyunusa commented Jan 31, 2024

hi, please i've been trying to locate the fix but i cant seem to figure out what you have as the proposed solution.
Can you please point me to it. Also having same issues here.
@erogol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants