Spaces:
Running on Zero
Running on Zero
Use bundled default audio prompt so conditionals are always prepared
Browse files
app.py
CHANGED
|
@@ -19,6 +19,12 @@ subprocess.run(
|
|
| 19 |
from chatterbox_flash import ChatterboxFlashTTS
|
| 20 |
|
| 21 |
MODEL_ID = "ResembleAI/chatterbox-flash"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
_tts = None
|
| 23 |
|
| 24 |
|
|
@@ -59,8 +65,13 @@ def generate_tts(
|
|
| 59 |
"backend": "torch",
|
| 60 |
}
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
wav = tts.generate(text_input[:300], **generate_kwargs)
|
| 66 |
return (tts.sr, wav.squeeze(0).cpu().numpy())
|
|
@@ -92,7 +103,8 @@ with gr.Blocks() as demo:
|
|
| 92 |
ref_wav = gr.Audio(
|
| 93 |
sources=["upload", "microphone"],
|
| 94 |
type="filepath",
|
| 95 |
-
|
|
|
|
| 96 |
)
|
| 97 |
|
| 98 |
with gr.Accordion("Advanced settings", open=False):
|
|
|
|
| 19 |
from chatterbox_flash import ChatterboxFlashTTS
|
| 20 |
|
| 21 |
MODEL_ID = "ResembleAI/chatterbox-flash"
|
| 22 |
+
# Chatterbox-Flash has no built-in voice: `generate()` raises
|
| 23 |
+
# "Conditioning not prepared" unless conditionals exist. Ship a default
|
| 24 |
+
# reference clip so zero-shot generation works without a user upload.
|
| 25 |
+
DEFAULT_AUDIO_PROMPT = os.path.join(
|
| 26 |
+
os.path.dirname(os.path.abspath(__file__)), "female_shadowheart4.flac"
|
| 27 |
+
)
|
| 28 |
_tts = None
|
| 29 |
|
| 30 |
|
|
|
|
| 65 |
"backend": "torch",
|
| 66 |
}
|
| 67 |
|
| 68 |
+
# Fall back to the bundled reference clip when the user supplies none, so
|
| 69 |
+
# conditionals are always prepared before generation.
|
| 70 |
+
prompt_path = audio_prompt_path or DEFAULT_AUDIO_PROMPT
|
| 71 |
+
generate_kwargs["audio_prompt_path"] = prompt_path
|
| 72 |
+
|
| 73 |
+
if tts.conds is None:
|
| 74 |
+
tts.prepare_conditionals(prompt_path, exaggeration=exaggeration)
|
| 75 |
|
| 76 |
wav = tts.generate(text_input[:300], **generate_kwargs)
|
| 77 |
return (tts.sr, wav.squeeze(0).cpu().numpy())
|
|
|
|
| 103 |
ref_wav = gr.Audio(
|
| 104 |
sources=["upload", "microphone"],
|
| 105 |
type="filepath",
|
| 106 |
+
value=DEFAULT_AUDIO_PROMPT,
|
| 107 |
+
label="Reference Audio (for voice cloning) — defaults to the bundled voice",
|
| 108 |
)
|
| 109 |
|
| 110 |
with gr.Accordion("Advanced settings", open=False):
|