Ubuntu
commited on
Commit
β’
9dafffe
1
Parent(s):
f6ffd85
add user flow control
Browse files
app.py
CHANGED
@@ -113,8 +113,8 @@ def embed_youtube(youtube_url):
|
|
113 |
|
114 |
def clear_on_audio_input(audio):
|
115 |
if audio is not None:
|
116 |
-
return "", gr.update(value="", visible=False), ""
|
117 |
-
return gr.update(), gr.update(), gr.update()
|
118 |
|
119 |
# Create the Gradio interface with improved aesthetics
|
120 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
@@ -135,21 +135,21 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
135 |
lines=10
|
136 |
)
|
137 |
|
138 |
-
run_button = gr.Button("π Transcribe Audio", variant="primary")
|
139 |
run_button.click(run_asr, inputs=[audio_input, youtube_input, timestamp_toggle, model_choice], outputs=[result])
|
140 |
|
141 |
-
# Update video player
|
142 |
youtube_input.change(
|
143 |
-
fn=embed_youtube,
|
144 |
inputs=[youtube_input],
|
145 |
-
outputs=[video_player, result, audio_input]
|
146 |
)
|
147 |
|
148 |
-
# Clear transcription, YouTube input,
|
149 |
audio_input.change(
|
150 |
fn=clear_on_audio_input,
|
151 |
inputs=[audio_input],
|
152 |
-
outputs=[result, video_player, youtube_input]
|
153 |
)
|
154 |
|
155 |
gr.Markdown("### How to use:")
|
|
|
113 |
|
114 |
def clear_on_audio_input(audio):
|
115 |
if audio is not None:
|
116 |
+
return "", gr.update(value="", visible=False), "", gr.update(interactive=True)
|
117 |
+
return gr.update(), gr.update(), gr.update(), gr.update(interactive=False)
|
118 |
|
119 |
# Create the Gradio interface with improved aesthetics
|
120 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
|
135 |
lines=10
|
136 |
)
|
137 |
|
138 |
+
run_button = gr.Button("π Transcribe Audio", variant="primary", interactive=False)
|
139 |
run_button.click(run_asr, inputs=[audio_input, youtube_input, timestamp_toggle, model_choice], outputs=[result])
|
140 |
|
141 |
+
# Update video player, clear transcription and audio input, and enable run button when YouTube URL is entered
|
142 |
youtube_input.change(
|
143 |
+
fn=lambda url: (*embed_youtube(url), gr.update(interactive=bool(url))),
|
144 |
inputs=[youtube_input],
|
145 |
+
outputs=[video_player, result, audio_input, run_button]
|
146 |
)
|
147 |
|
148 |
+
# Clear transcription, YouTube input, video player, and update run button when audio is input
|
149 |
audio_input.change(
|
150 |
fn=clear_on_audio_input,
|
151 |
inputs=[audio_input],
|
152 |
+
outputs=[result, video_player, youtube_input, run_button]
|
153 |
)
|
154 |
|
155 |
gr.Markdown("### How to use:")
|