Skip to content

Commit f79d2db

Browse files
committed
hotfix: use legacy kokoro repo for demo
1 parent abbd0d5 commit f79d2db

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

demo/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def load_text_to_text_model():
3030
@st.cache_resource
3131
def load_text_to_speech_model():
3232
if os.environ.get("HF_SPACE") == "TRUE":
33-
return load_tts_model("hexgrad/Kokoro-82M/kokoro-v0_19.pth")
33+
return load_tts_model("hexgrad/kLegacy/v0.19/kokoro-v0_19.pth")
3434
else:
3535
return load_tts_model("OuteAI/OuteTTS-0.2-500M-GGUF/OuteTTS-0.2-500M-FP16.gguf")
3636

@@ -137,7 +137,7 @@ def gen_button_clicked():
137137
]
138138
else:
139139
tts_link = "- [OuteAI/OuteTTS-0.2-500M](https://huggingface.co/OuteAI/OuteTTS-0.2-500M-GGUF)"
140-
SPEARES = DEFAULT_SPEAKERS
140+
SPEAKERS = DEFAULT_SPEAKERS
141141

142142
st.markdown(
143143
"For this demo, we are using the following models: \n"

demo/notebook.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
"text_model = load_llama_cpp_model(\n",
208208
" \"bartowski/Qwen2.5-3B-Instruct-GGUF/Qwen2.5-3B-Instruct-f16.gguf\"\n",
209209
")\n",
210-
"speech_model = load_tts_model(\"hexgrad/Kokoro-82M/kokoro-v0_19.pth\")"
210+
"speech_model = load_tts_model(\"hexgrad/kLegacy/v0.19/kokoro-v0_19.pth\")"
211211
]
212212
},
213213
{

src/document_to_podcast/inference/model_loaders.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,28 +81,25 @@ def _load_oute_tts(model_id: str, **kwargs) -> TTSModel:
8181
)
8282

8383

84-
def _load_kokoro_tts(model_id: str, **kwargs) -> TTSModel:
84+
def _load_kokoro_legacy_tts(model_id: str, **kwargs) -> TTSModel:
8585
from document_to_podcast.inference.kokoro.models import build_model
8686

87-
org, repo, filename = model_id.split("/")
88-
downloaded_model = hf_hub_download(f"{org}/{repo}", filename)
87+
org, repo, kokoro_version, filename = model_id.split("/")
88+
downloaded_model = hf_hub_download(f"{org}/{repo}", f"{kokoro_version}/{filename}")
8989
model = build_model(downloaded_model)
9090
return TTSModel(
9191
model=model,
9292
model_id=model_id,
9393
sample_rate=24000,
94-
custom_args={
95-
"org": org,
96-
"repo": repo,
97-
},
94+
custom_args={"org": org, "repo": repo, "kokoro_version": kokoro_version},
9895
)
9996

10097

10198
TTS_LOADERS = {
10299
# To add support for your model, add it here in the format {model_id} : _load_function
103100
"OuteAI/OuteTTS-0.1-350M-GGUF/OuteTTS-0.1-350M-FP16.gguf": _load_oute_tts,
104101
"OuteAI/OuteTTS-0.2-500M-GGUF/OuteTTS-0.2-500M-FP16.gguf": _load_oute_tts,
105-
"hexgrad/Kokoro-82M/kokoro-v0_19.pth": _load_kokoro_tts,
102+
"hexgrad/kLegacy/v0.19/kokoro-v0_19.pth": _load_kokoro_legacy_tts,
106103
}
107104

108105

src/document_to_podcast/inference/text_to_speech.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ def _text_to_speech_oute(
4040
return output_as_np
4141

4242

43-
def _text_to_speech_kokoro(input_text, model, voice_profile, org, repo):
43+
def _text_to_speech_kokoro(input_text, model, voice_profile, org, repo, kokoro_version):
4444
import torch
4545
from huggingface_hub import hf_hub_download
4646
from document_to_podcast.inference.kokoro.infer import generate
4747

48-
downloaded_voice = hf_hub_download(f"{org}/{repo}", f"voices/{voice_profile}.pt")
48+
downloaded_voice = hf_hub_download(
49+
f"{org}/{repo}", f"{kokoro_version}/voices/{voice_profile}.pt"
50+
)
4951
voicepack = torch.load(downloaded_voice).to(
5052
torch.device("cuda" if torch.cuda.is_available() else "cpu")
5153
)
@@ -58,7 +60,7 @@ def _text_to_speech_kokoro(input_text, model, voice_profile, org, repo):
5860
# To add support for your model, add it here in the format {model_id} : _inference_function
5961
"OuteAI/OuteTTS-0.1-350M-GGUF/OuteTTS-0.1-350M-FP16.gguf": _text_to_speech_oute,
6062
"OuteAI/OuteTTS-0.2-500M-GGUF/OuteTTS-0.2-500M-FP16.gguf": _text_to_speech_oute,
61-
"hexgrad/Kokoro-82M/kokoro-v0_19.pth": _text_to_speech_kokoro,
63+
"hexgrad/kLegacy/v0.19/kokoro-v0_19.pth": _text_to_speech_kokoro,
6264
}
6365

6466

0 commit comments

Comments
 (0)