Update app.py
Browse files
app.py
CHANGED
|
@@ -413,10 +413,21 @@ def synthesize_speech(
|
|
| 413 |
# Save master WAV (lossless) and MP3 preview
|
| 414 |
ts = time.strftime("%Y%m%d-%H%M%S")
|
| 415 |
master_wav_path = str(OUTPUT_DIR / f"lishani_{ts}_{uuid.uuid4().hex}.wav")
|
|
|
|
|
|
|
| 416 |
processed_seg.export(master_wav_path, format="wav")
|
| 417 |
|
| 418 |
-
|
| 419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 420 |
|
| 421 |
return mp3_path, master_wav_path
|
| 422 |
|
|
|
|
| 413 |
# Save master WAV (lossless) and MP3 preview
|
| 414 |
ts = time.strftime("%Y%m%d-%H%M%S")
|
| 415 |
master_wav_path = str(OUTPUT_DIR / f"lishani_{ts}_{uuid.uuid4().hex}.wav")
|
| 416 |
+
|
| 417 |
+
# Always write WAV (this is very reliable)
|
| 418 |
processed_seg.export(master_wav_path, format="wav")
|
| 419 |
|
| 420 |
+
# Try MP3, but don't fail the whole call if it breaks
|
| 421 |
+
mp3_path = None
|
| 422 |
+
try:
|
| 423 |
+
mp3_path = str(Path(master_wav_path).with_suffix(".mp3"))
|
| 424 |
+
processed_seg.export(mp3_path, format="mp3", bitrate="320k")
|
| 425 |
+
except Exception as e:
|
| 426 |
+
print("MP3 export failed; returning WAV only:", e)
|
| 427 |
+
mp3_path = None
|
| 428 |
+
|
| 429 |
+
# Return whatever we have: the Audio output will happily preview WAV too
|
| 430 |
+
return mp3_path or master_wav_path, master_wav_path
|
| 431 |
|
| 432 |
return mp3_path, master_wav_path
|
| 433 |
|