Spaces:
Running on Zero
Running on Zero
Upload app.py
Browse files
app.py
CHANGED
|
@@ -31,14 +31,17 @@ def generate_tts(text: str, voice: str):
|
|
| 31 |
m = get_model()
|
| 32 |
clean_voice = voice.replace("pocket-", "").replace("-", "_")
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
if isinstance(audio, torch.Tensor):
|
| 44 |
audio_np = audio.detach().cpu().numpy()
|
|
@@ -51,7 +54,7 @@ def generate_tts(text: str, voice: str):
|
|
| 51 |
demo = gr.Interface(
|
| 52 |
fn=generate_tts,
|
| 53 |
inputs=[
|
| 54 |
-
gr.Textbox(label="Text to speak", value="Hello!
|
| 55 |
gr.Dropdown(choices=VOICE_LIST, value="stuart_bell", label="Voice"),
|
| 56 |
],
|
| 57 |
outputs=gr.Audio(label="Generated Audio", type="numpy"),
|
|
|
|
| 31 |
m = get_model()
|
| 32 |
clean_voice = voice.replace("pocket-", "").replace("-", "_")
|
| 33 |
|
| 34 |
+
# 1. Get the voice state dict for the selected voice
|
| 35 |
+
if hasattr(m, "get_voice_state"):
|
| 36 |
+
voice_state = m.get_voice_state(clean_voice)
|
| 37 |
+
elif hasattr(m, "load_voice_state"):
|
| 38 |
+
voice_state = m.load_voice_state(clean_voice)
|
| 39 |
+
else:
|
| 40 |
+
# Fallback to empty dict or voice lookup
|
| 41 |
+
voice_state = m.get_state_for_voice(clean_voice) if hasattr(m, "get_state_for_voice") else {}
|
| 42 |
+
|
| 43 |
+
# 2. Generate audio with (voice_state_dict, text)
|
| 44 |
+
audio = m.generate_audio(voice_state, clean_text)
|
| 45 |
|
| 46 |
if isinstance(audio, torch.Tensor):
|
| 47 |
audio_np = audio.detach().cpu().numpy()
|
|
|
|
| 54 |
demo = gr.Interface(
|
| 55 |
fn=generate_tts,
|
| 56 |
inputs=[
|
| 57 |
+
gr.Textbox(label="Text to speak", value="Hello! This is genuine Kyutai Pocket TTS running smoothly."),
|
| 58 |
gr.Dropdown(choices=VOICE_LIST, value="stuart_bell", label="Voice"),
|
| 59 |
],
|
| 60 |
outputs=gr.Audio(label="Generated Audio", type="numpy"),
|