Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -94,20 +94,38 @@ async def create_demo():
|
|
| 94 |
voice_dropdown = gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value="")
|
| 95 |
rate_slider = gr.Slider(minimum=-50, maximum=50, value=0, label="Rate Adjustment (%)", step=1)
|
| 96 |
pitch_slider = gr.Slider(minimum=-20, maximum=20, value=0, label="Pitch Adjustment (Hz)", step=1)
|
|
|
|
|
|
|
| 97 |
|
| 98 |
with gr.Column():
|
| 99 |
-
|
|
|
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
| 104 |
|
| 105 |
generate_button.click(
|
| 106 |
fn=tts_interface,
|
| 107 |
inputs=[text_input, voice_dropdown, rate_slider, pitch_slider],
|
| 108 |
outputs=[output_audio, output_srt, warning_msg]
|
| 109 |
)
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
return demo
|
| 112 |
|
| 113 |
# 运行应用
|
|
|
|
| 94 |
voice_dropdown = gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value="")
|
| 95 |
rate_slider = gr.Slider(minimum=-50, maximum=50, value=0, label="Rate Adjustment (%)", step=1)
|
| 96 |
pitch_slider = gr.Slider(minimum=-20, maximum=20, value=0, label="Pitch Adjustment (Hz)", step=1)
|
| 97 |
+
|
| 98 |
+
generate_button = gr.Button("Generate Audio and Subtitles", variant="primary")
|
| 99 |
|
| 100 |
with gr.Column():
|
| 101 |
+
output_audio = gr.Audio(label="Generated Audio", type="filepath")
|
| 102 |
+
audio_download_button = gr.Button("Download Audio")
|
| 103 |
|
| 104 |
+
output_srt = gr.File(label="Generated SRT", file_count="single")
|
| 105 |
+
srt_download_button = gr.Button("Download SRT")
|
| 106 |
+
|
| 107 |
+
warning_msg = gr.Markdown(label="Warning", visible=False)
|
| 108 |
|
| 109 |
generate_button.click(
|
| 110 |
fn=tts_interface,
|
| 111 |
inputs=[text_input, voice_dropdown, rate_slider, pitch_slider],
|
| 112 |
outputs=[output_audio, output_srt, warning_msg]
|
| 113 |
)
|
| 114 |
+
|
| 115 |
+
audio_download_button.click(
|
| 116 |
+
fn=lambda audio: audio,
|
| 117 |
+
inputs=output_audio,
|
| 118 |
+
outputs=None,
|
| 119 |
+
_js="(function(audio) { if(audio) { window.open(audio); } })"
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
srt_download_button.click(
|
| 123 |
+
fn=lambda srt: srt,
|
| 124 |
+
inputs=output_srt,
|
| 125 |
+
outputs=None,
|
| 126 |
+
_js="(function(srt) { if(srt) { window.open(srt); } })"
|
| 127 |
+
)
|
| 128 |
+
|
| 129 |
return demo
|
| 130 |
|
| 131 |
# 运行应用
|