hivecorp commited on
Commit
2ff3127
·
verified ·
1 Parent(s): 4c25f4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -18
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
- # Format pitch and rate strings
358
- pitch_str = f"{pitch:+d}Hz" if pitch != 0 else "+0Hz"
359
- rate_str = f"{rate:+d}%" if rate != 0 else "+0%"
360
-
361
- srt_path, audio_path = await generate_accurate_srt(
362
- text,
363
- voice_options[voice],
364
- rate_str,
365
- pitch_str,
366
- words_per_line,
367
- lines_per_segment,
368
- enable_ssml,
369
- use_cache,
370
- pause_after_period,
371
- pause_after_comma
372
- )
373
-
374
- return srt_path, audio_path, audio_path
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = {