Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -354,24 +354,44 @@ async def generate_accurate_srt(text: str, voice: str, rate: str, pitch: str, wo
|
|
| 354 |
return srt_path, audio_path
|
| 355 |
|
| 356 |
async def process_text(text, pitch, rate, voice, words_per_line, lines_per_segment, enable_ssml, use_cache, pause_after_period, pause_after_comma):
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
|
| 376 |
# Voice options dictionary (same as before)
|
| 377 |
voice_options = {
|
|
|
|
| 354 |
return srt_path, audio_path
|
| 355 |
|
| 356 |
async def process_text(text, pitch, rate, voice, words_per_line, lines_per_segment, enable_ssml, use_cache, pause_after_period, pause_after_comma):
|
| 357 |
+
try:
|
| 358 |
+
# Format pitch and rate strings
|
| 359 |
+
pitch_str = f"{pitch:+d}Hz" if pitch != 0 else "+0Hz"
|
| 360 |
+
rate_str = f"{rate:+d}%" if rate != 0 else "+0%"
|
| 361 |
+
|
| 362 |
+
status_html = "<p>Processing started...</p>"
|
| 363 |
+
|
| 364 |
+
srt_path, audio_path = await generate_accurate_srt(
|
| 365 |
+
text,
|
| 366 |
+
voice_options[voice],
|
| 367 |
+
rate_str,
|
| 368 |
+
pitch_str,
|
| 369 |
+
words_per_line,
|
| 370 |
+
lines_per_segment,
|
| 371 |
+
enable_ssml,
|
| 372 |
+
use_cache,
|
| 373 |
+
pause_after_period,
|
| 374 |
+
pause_after_comma
|
| 375 |
+
)
|
| 376 |
+
|
| 377 |
+
status_html = """
|
| 378 |
+
<div style='color: green; padding: 10px;'>
|
| 379 |
+
<p>✓ Processing completed successfully!</p>
|
| 380 |
+
<p>- SRT file generated</p>
|
| 381 |
+
<p>- Audio file generated</p>
|
| 382 |
+
</div>
|
| 383 |
+
"""
|
| 384 |
+
|
| 385 |
+
return srt_path, audio_path, audio_path, status_html
|
| 386 |
+
|
| 387 |
+
except Exception as e:
|
| 388 |
+
error_html = f"""
|
| 389 |
+
<div style='color: red; padding: 10px;'>
|
| 390 |
+
<p>❌ Error during processing:</p>
|
| 391 |
+
<p>{str(e)}</p>
|
| 392 |
+
</div>
|
| 393 |
+
"""
|
| 394 |
+
return None, None, None, error_html
|
| 395 |
|
| 396 |
# Voice options dictionary (same as before)
|
| 397 |
voice_options = {
|