Update app.py
Browse files
app.py
CHANGED
|
@@ -462,9 +462,8 @@ async def process_text_with_progress(
|
|
| 462 |
):
|
| 463 |
# Input validation
|
| 464 |
if not text or text.strip() == "":
|
| 465 |
-
return None, None, None,
|
| 466 |
|
| 467 |
-
# Format pitch and rate strings
|
| 468 |
pitch_str = f"{pitch:+d}Hz" if pitch != 0 else "+0Hz"
|
| 469 |
rate_str = f"{rate:+d}%" if rate != 0 else "+0%"
|
| 470 |
|
|
@@ -485,21 +484,21 @@ async def process_text_with_progress(
|
|
| 485 |
parallel=parallel_processing
|
| 486 |
)
|
| 487 |
|
| 488 |
-
# ✅ Success: return all 7 values
|
| 489 |
return (
|
| 490 |
srt_path,
|
| 491 |
audio_path,
|
| 492 |
audio_path,
|
| 493 |
-
|
| 494 |
-
"",
|
| 495 |
create_download_link(srt_path, "Download Subtitles (.srt)"),
|
| 496 |
create_download_link(audio_path, "Download Audio (.mp3)")
|
| 497 |
)
|
| 498 |
|
| 499 |
except TTSError as e:
|
| 500 |
-
return None, None, None,
|
| 501 |
except Exception as e:
|
| 502 |
-
return None, None, None,
|
|
|
|
| 503 |
|
| 504 |
|
| 505 |
# Voice options dictionary
|
|
@@ -632,15 +631,15 @@ with gr.Blocks(title="Advanced TTS with Configurable SRT Generation") as app:
|
|
| 632 |
parallel_processing
|
| 633 |
],
|
| 634 |
outputs=[
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
],
|
| 643 |
-
|
| 644 |
)
|
| 645 |
|
| 646 |
if __name__ == "__main__":
|
|
|
|
| 462 |
):
|
| 463 |
# Input validation
|
| 464 |
if not text or text.strip() == "":
|
| 465 |
+
return None, None, None, "Please enter some text to convert to speech.", "", None, None
|
| 466 |
|
|
|
|
| 467 |
pitch_str = f"{pitch:+d}Hz" if pitch != 0 else "+0Hz"
|
| 468 |
rate_str = f"{rate:+d}%" if rate != 0 else "+0%"
|
| 469 |
|
|
|
|
| 484 |
parallel=parallel_processing
|
| 485 |
)
|
| 486 |
|
|
|
|
| 487 |
return (
|
| 488 |
srt_path,
|
| 489 |
audio_path,
|
| 490 |
audio_path,
|
| 491 |
+
"", # error_output (no error)
|
| 492 |
+
"", # extra message output (optional)
|
| 493 |
create_download_link(srt_path, "Download Subtitles (.srt)"),
|
| 494 |
create_download_link(audio_path, "Download Audio (.mp3)")
|
| 495 |
)
|
| 496 |
|
| 497 |
except TTSError as e:
|
| 498 |
+
return None, None, None, f"TTS Error: {str(e)}", "", None, None
|
| 499 |
except Exception as e:
|
| 500 |
+
return None, None, None, f"Unexpected error: {str(e)}", "", None, None
|
| 501 |
+
|
| 502 |
|
| 503 |
|
| 504 |
# Voice options dictionary
|
|
|
|
| 631 |
parallel_processing
|
| 632 |
],
|
| 633 |
outputs=[
|
| 634 |
+
srt_file, # gr.File
|
| 635 |
+
audio_file, # gr.File
|
| 636 |
+
audio_output, # gr.Audio
|
| 637 |
+
error_output, # gr.Textbox
|
| 638 |
+
error_output, # gr.Textbox (or gr.Label)
|
| 639 |
+
srt_download, # gr.HTML
|
| 640 |
+
audio_download # gr.HTML
|
| 641 |
+
],
|
| 642 |
+
api_name="generate"
|
| 643 |
)
|
| 644 |
|
| 645 |
if __name__ == "__main__":
|