Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -164,10 +164,94 @@ async def cancel_job(job_id: str):
|
|
| 164 |
|
| 165 |
# Initialize Gradio interface
|
| 166 |
with gr.Blocks() as gradio_app:
|
| 167 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
-
# Mount Gradio app
|
| 170 |
app = gr.mount_gradio_app(app, gradio_app, path="/")
|
| 171 |
|
|
|
|
| 172 |
if __name__ == "__main__":
|
| 173 |
uvicorn.run("fastapi_app:app", host="0.0.0.0", port=8000, reload=True)
|
|
|
|
| 164 |
|
| 165 |
# Initialize Gradio interface
|
| 166 |
with gr.Blocks() as gradio_app:
|
| 167 |
+
gr.Markdown("# Advanced TTS with Configurable SRT Generation")
|
| 168 |
+
gr.Markdown("Generate perfectly synchronized audio and subtitles with natural speech patterns.")
|
| 169 |
+
|
| 170 |
+
with gr.Row():
|
| 171 |
+
with gr.Column(scale=3):
|
| 172 |
+
text_input = gr.Textbox(label="Enter Text", lines=10, placeholder="Enter your text here...")
|
| 173 |
+
|
| 174 |
+
with gr.Column(scale=2):
|
| 175 |
+
voice_dropdown = gr.Dropdown(
|
| 176 |
+
label="Select Voice",
|
| 177 |
+
choices=list(voice_options.keys()),
|
| 178 |
+
value="Jenny Female"
|
| 179 |
+
)
|
| 180 |
+
pitch_slider = gr.Slider(
|
| 181 |
+
label="Pitch Adjustment (Hz)",
|
| 182 |
+
minimum=-10,
|
| 183 |
+
maximum=10,
|
| 184 |
+
value=0,
|
| 185 |
+
step=1
|
| 186 |
+
)
|
| 187 |
+
rate_slider = gr.Slider(
|
| 188 |
+
label="Rate Adjustment (%)",
|
| 189 |
+
minimum=-25,
|
| 190 |
+
maximum=25,
|
| 191 |
+
value=0,
|
| 192 |
+
step=1
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
+
with gr.Row():
|
| 196 |
+
with gr.Column():
|
| 197 |
+
words_per_line = gr.Slider(
|
| 198 |
+
label="Words per Line",
|
| 199 |
+
minimum=3,
|
| 200 |
+
maximum=12,
|
| 201 |
+
value=6,
|
| 202 |
+
step=1,
|
| 203 |
+
info="Controls how many words appear on each line of the subtitle"
|
| 204 |
+
)
|
| 205 |
+
with gr.Column():
|
| 206 |
+
lines_per_segment = gr.Slider(
|
| 207 |
+
label="Lines per Segment",
|
| 208 |
+
minimum=1,
|
| 209 |
+
maximum=4,
|
| 210 |
+
value=2,
|
| 211 |
+
step=1,
|
| 212 |
+
info="Controls how many lines appear in each subtitle segment"
|
| 213 |
+
)
|
| 214 |
+
with gr.Column():
|
| 215 |
+
parallel_processing = gr.Checkbox(
|
| 216 |
+
label="Enable Parallel Processing",
|
| 217 |
+
value=True,
|
| 218 |
+
info="Process multiple segments simultaneously for faster conversion"
|
| 219 |
+
)
|
| 220 |
+
|
| 221 |
+
submit_btn = gr.Button("Generate Audio & Subtitles")
|
| 222 |
+
error_output = gr.Textbox(label="Status", visible=False)
|
| 223 |
+
|
| 224 |
+
with gr.Row():
|
| 225 |
+
with gr.Column():
|
| 226 |
+
audio_output = gr.Audio(label="Preview Audio")
|
| 227 |
+
with gr.Column():
|
| 228 |
+
srt_file = gr.File(label="Download SRT")
|
| 229 |
+
audio_file = gr.File(label="Download Audio")
|
| 230 |
+
|
| 231 |
+
submit_btn.click(
|
| 232 |
+
fn=process_text_with_progress,
|
| 233 |
+
inputs=[
|
| 234 |
+
text_input,
|
| 235 |
+
pitch_slider,
|
| 236 |
+
rate_slider,
|
| 237 |
+
voice_dropdown,
|
| 238 |
+
words_per_line,
|
| 239 |
+
lines_per_segment,
|
| 240 |
+
parallel_processing
|
| 241 |
+
],
|
| 242 |
+
outputs=[
|
| 243 |
+
srt_file,
|
| 244 |
+
audio_file,
|
| 245 |
+
audio_output,
|
| 246 |
+
error_output,
|
| 247 |
+
error_output
|
| 248 |
+
],
|
| 249 |
+
api_name="generate"
|
| 250 |
+
)
|
| 251 |
|
| 252 |
+
# Mount Gradio app to FastAPI
|
| 253 |
app = gr.mount_gradio_app(app, gradio_app, path="/")
|
| 254 |
|
| 255 |
+
# Start the FastAPI server
|
| 256 |
if __name__ == "__main__":
|
| 257 |
uvicorn.run("fastapi_app:app", host="0.0.0.0", port=8000, reload=True)
|