hivecorp commited on
Commit
46d2980
·
verified ·
1 Parent(s): ae05d26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -47,7 +47,7 @@ async def generate_accurate_srt(batch_text, batch_num, start_offset, pitch, rate
47
  audio_file = f"batch_{batch_num}_audio.wav"
48
 
49
  # Generate the audio using edge-tts
50
- tts = edge_tts.Communicate(batch_text, voice, rate=rate, pitch=f"{pitch}Hz")
51
  await tts.save(audio_file)
52
 
53
  # Get the actual length of the audio file
@@ -116,9 +116,11 @@ async def batch_process_srt_and_audio(script_text, pitch, rate, voice, progress=
116
  return final_srt_path, final_audio_path
117
 
118
  # Gradio interface function
119
- async def process_script(script_text, pitch, rate, voice, _):
 
 
120
  formatted_rate = f"{'+' if rate > 0 else ''}{int(rate)}%"
121
- srt_path, audio_path = await batch_process_srt_and_audio(script_text, pitch, formatted_rate, voice_options[voice])
122
  return srt_path, audio_path, audio_path
123
 
124
  # Gradio interface setup
@@ -170,14 +172,15 @@ app = gr.Interface(
170
  gr.Slider(label="Pitch Adjustment (Hz)", minimum=-100, maximum=100, step=1, value=1),
171
  gr.Slider(label="Rate Adjustment (%)", minimum=-100, maximum=100, step=1, value=1),
172
  gr.Dropdown(label="Select Voice", choices=list(voice_options.keys()), value="Andrew"),
173
- gr.Button("Submit") # Create a submit button with text "Submit"
174
  ],
175
  outputs=[
176
- gr.File(label="Download SRT"),
177
- gr.File(label="Download Audio"),
178
  gr.Audio(label="Audio Playback")
179
  ],
180
- live=False # Set live to False to prevent real-time updates
 
 
181
  )
182
 
183
  app.launch()
 
47
  audio_file = f"batch_{batch_num}_audio.wav"
48
 
49
  # Generate the audio using edge-tts
50
+ tts = edge_tts.Communicate(batch_text, voice, rate=rate, pitch=pitch)
51
  await tts.save(audio_file)
52
 
53
  # Get the actual length of the audio file
 
116
  return final_srt_path, final_audio_path
117
 
118
  # Gradio interface function
119
+ async def process_script(script_text, pitch, rate, voice):
120
+ # Format pitch correctly for edge-tts
121
+ pitch_str = f"{pitch}Hz" if pitch != 0 else "0Hz"
122
  formatted_rate = f"{'+' if rate > 0 else ''}{int(rate)}%"
123
+ srt_path, audio_path = await batch_process_srt_and_audio(script_text, pitch_str, formatted_rate, voice_options[voice])
124
  return srt_path, audio_path, audio_path
125
 
126
  # Gradio interface setup
 
172
  gr.Slider(label="Pitch Adjustment (Hz)", minimum=-100, maximum=100, step=1, value=1),
173
  gr.Slider(label="Rate Adjustment (%)", minimum=-100, maximum=100, step=1, value=1),
174
  gr.Dropdown(label="Select Voice", choices=list(voice_options.keys()), value="Andrew"),
 
175
  ],
176
  outputs=[
177
+ gr.File(label="Download SRT File"),
178
+ gr.File(label="Download Audio File"),
179
  gr.Audio(label="Audio Playback")
180
  ],
181
+ title="Text-to-Speech with SRT Generation",
182
+ description="Convert your script into audio and generate subtitles.",
183
+ theme="compact",
184
  )
185
 
186
  app.launch()