SefyanKehail
commited on
Commit
·
e244b7c
1
Parent(s):
a064a63
added progress instead of spinner
Browse files
app.py
CHANGED
|
@@ -65,18 +65,16 @@ def convert_speech(filename, progress=gr.Progress()):
|
|
| 65 |
|
| 66 |
"""Convert to the target speaker:"""
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
|
| 73 |
def clear_components():
|
| 74 |
return None, None
|
| 75 |
|
| 76 |
-
def
|
| 77 |
-
|
| 78 |
-
return gr.update(interactive=True), gr.update(value=None) # Enable button and hide progress
|
| 79 |
-
return gr.update(interactive=False), gr.update(value=None) # Hide progress if no audio
|
| 80 |
|
| 81 |
# Gradio interface
|
| 82 |
with gr.Blocks() as interface:
|
|
@@ -87,17 +85,15 @@ with gr.Blocks() as interface:
|
|
| 87 |
with gr.Column():
|
| 88 |
audio_input = gr.Audio(type="filepath", label="Upload Audio", sources=["upload", "microphone"])
|
| 89 |
convert_button = gr.Button("Convert Speech", interactive=False)
|
| 90 |
-
|
| 91 |
-
|
| 92 |
with gr.Column():
|
| 93 |
converted_audio = gr.Audio(type="numpy", label="Converted Speech")
|
| 94 |
|
| 95 |
|
| 96 |
-
|
| 97 |
-
progress.update(visible=True) # Show progress
|
| 98 |
-
return enable_convert_button(audio, progress)
|
| 99 |
|
| 100 |
-
audio_input.change(
|
| 101 |
|
| 102 |
convert_button.click(convert_speech, inputs=[audio_input], outputs=[converted_audio])
|
| 103 |
|
|
|
|
| 65 |
|
| 66 |
"""Convert to the target speaker:"""
|
| 67 |
|
| 68 |
+
def enable_convert_button(audio):
|
| 69 |
+
if audio is not None:
|
| 70 |
+
return gr.update(interactive=True)
|
| 71 |
+
return gr.update(interactive=False)
|
| 72 |
|
| 73 |
def clear_components():
|
| 74 |
return None, None
|
| 75 |
|
| 76 |
+
def stop_recording():
|
| 77 |
+
return gr.update(value="Processing audio...", visible=True)
|
|
|
|
|
|
|
| 78 |
|
| 79 |
# Gradio interface
|
| 80 |
with gr.Blocks() as interface:
|
|
|
|
| 85 |
with gr.Column():
|
| 86 |
audio_input = gr.Audio(type="filepath", label="Upload Audio", sources=["upload", "microphone"])
|
| 87 |
convert_button = gr.Button("Convert Speech", interactive=False)
|
| 88 |
+
info = gr.Info(visible=False)
|
| 89 |
+
|
| 90 |
with gr.Column():
|
| 91 |
converted_audio = gr.Audio(type="numpy", label="Converted Speech")
|
| 92 |
|
| 93 |
|
| 94 |
+
audio_input.stop_recording(stop_recording, inputs=[], outputs=[info])
|
|
|
|
|
|
|
| 95 |
|
| 96 |
+
audio_input.change(enable_convert_button, inputs=[audio_input], outputs=[convert_button])
|
| 97 |
|
| 98 |
convert_button.click(convert_speech, inputs=[audio_input], outputs=[converted_audio])
|
| 99 |
|