Spaces:
Running on Zero
Running on Zero
Robustly handle audio_ref dict or object in generate_audio endpoint
Browse files
app.py
CHANGED
|
@@ -198,7 +198,14 @@ def generate_audio(
|
|
| 198 |
raise gr.Error("Prompt is empty.")
|
| 199 |
|
| 200 |
t0 = time.time()
|
| 201 |
-
ref_path =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
output = tempfile.mktemp(suffix=".wav", prefix="dramabox_")
|
| 204 |
tts.generate_to_file(
|
|
|
|
| 198 |
raise gr.Error("Prompt is empty.")
|
| 199 |
|
| 200 |
t0 = time.time()
|
| 201 |
+
ref_path = None
|
| 202 |
+
if audio_ref:
|
| 203 |
+
if isinstance(audio_ref, dict):
|
| 204 |
+
ref_path = audio_ref.get("path")
|
| 205 |
+
elif hasattr(audio_ref, "path"):
|
| 206 |
+
ref_path = audio_ref.path
|
| 207 |
+
if ref_path and not os.path.exists(ref_path):
|
| 208 |
+
ref_path = None
|
| 209 |
|
| 210 |
output = tempfile.mktemp(suffix=".wav", prefix="dramabox_")
|
| 211 |
tts.generate_to_file(
|