Timemaster commited on
Commit
da134c2
·
verified ·
1 Parent(s): 8d88124

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -31,7 +31,7 @@ def text_to_speech_gtts(text, language_name, slow_speed): # ADDED slow_speed
31
  tmp_path = tmp_file.name
32
 
33
  # Initialize gTTS object - USE slow_speed from input
34
- # tts = gTTS(text=text, lang=lang_code, slow=slow_speed)
35
 
36
  # Save the audio file (synchronous operation) [cite: 4]
37
  tts.save(tmp_path)
@@ -40,11 +40,16 @@ def text_to_speech_gtts(text, language_name, slow_speed): # ADDED slow_speed
40
 
41
  except Exception as e:
42
  # Handle all gTTS-related errors (e.g., language not supported, network failure)
43
- return "ERROR: Failed to generate audio. Details: {str(e)}"
44
 
45
 
46
  # --- Modern Gradio Component Syntax (Translated UI) ---
47
- input_text = gr.Textbox(lines=5, label="Input Text")
 
 
 
 
 
48
  output_text = gr.Textbox(label="Output Text")
49
  output_audio = gr.Audio(
50
  type="filepath",
@@ -70,11 +75,6 @@ interface = gr.Interface(
70
  description="Convert text into audio using the reliable Google Text-to-Speech service. (Max 100 characters for optimal stability)"
71
  )
72
 
73
- speech_speed = gr.Radio(
74
- choices=[("Normal", False), ("Slow", True)], # Custom labels and corresponding boolean values
75
- value=False, # Default to Normal speed
76
- label="Speech Speed"
77
- )
78
 
79
  # --- Standard Synchronous Launch Command ---
80
  if __name__ == "__main__":
 
31
  tmp_path = tmp_file.name
32
 
33
  # Initialize gTTS object - USE slow_speed from input
34
+ tts = gTTS(text=text, lang=lang_code, slow=slow_speed)
35
 
36
  # Save the audio file (synchronous operation) [cite: 4]
37
  tts.save(tmp_path)
 
40
 
41
  except Exception as e:
42
  # Handle all gTTS-related errors (e.g., language not supported, network failure)
43
+ return f"ERROR: Failed to generate audio. Details: {str(e)}", None [cite: 5]
44
 
45
 
46
  # --- Modern Gradio Component Syntax (Translated UI) ---
47
+ input_text = gr.Textbox(lines=5, label="Input Text")
48
+ speech_speed = gr.Radio(
49
+ choices=[("Normal", False), ("Slow", True)], # Custom labels and corresponding boolean values
50
+ value=False, # Default to Normal speed
51
+ label="Speech Speed"
52
+ )
53
  output_text = gr.Textbox(label="Output Text")
54
  output_audio = gr.Audio(
55
  type="filepath",
 
75
  description="Convert text into audio using the reliable Google Text-to-Speech service. (Max 100 characters for optimal stability)"
76
  )
77
 
 
 
 
 
 
78
 
79
  # --- Standard Synchronous Launch Command ---
80
  if __name__ == "__main__":