Update app.py
Browse filesupdate the gui, clear the output and update the last_modified.
app.py
CHANGED
@@ -122,18 +122,18 @@ def embed_youtube(youtube_url):
|
|
122 |
video_id = fetch_youtube_id(youtube_url)
|
123 |
embed_html = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_id}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'
|
124 |
last_modified = 2;
|
125 |
-
return gr.update(value=embed_html, visible=True), "",
|
126 |
except Exception as e:
|
127 |
-
return gr.update(value="", visible=False), f"Invalid YouTube URL: {str(e)}",
|
128 |
-
return gr.update(value="", visible=False), "",
|
129 |
|
130 |
def clear_on_audio_input(audio):
|
131 |
global last_modified
|
132 |
|
133 |
if audio is not None:
|
134 |
last_modified =1
|
135 |
-
return "", gr.update(
|
136 |
-
return gr.update(), gr.update(), gr.update(), gr.update(
|
137 |
|
138 |
# Create the Gradio interface with improved aesthetics
|
139 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
@@ -167,7 +167,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
167 |
)
|
168 |
# Update video player, clear transcription and audio input, and enable run button when YouTube URL is entered
|
169 |
youtube_input.change(
|
170 |
-
fn=lambda url: (*embed_youtube(url), gr.update(interactive=bool(url))),
|
|
|
171 |
inputs=[youtube_input],
|
172 |
outputs=[video_player, result, audio_input, run_button]
|
173 |
)
|
|
|
122 |
video_id = fetch_youtube_id(youtube_url)
|
123 |
embed_html = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_id}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'
|
124 |
last_modified = 2;
|
125 |
+
return gr.update(value=embed_html, visible=True), "", gr.update(), gr.update(interactive=bool(url))
|
126 |
except Exception as e:
|
127 |
+
return gr.update(value="", visible=False), f"Invalid YouTube URL: {str(e)}", gr.update(),gr.update()
|
128 |
+
return gr.update(value="", visible=False), "", gr.update(), gr.update()
|
129 |
|
130 |
def clear_on_audio_input(audio):
|
131 |
global last_modified
|
132 |
|
133 |
if audio is not None:
|
134 |
last_modified =1
|
135 |
+
return "", gr.update(), gr.update(), gr.update(interactive=True)
|
136 |
+
return gr.update(), gr.update(), gr.update(), gr.update()
|
137 |
|
138 |
# Create the Gradio interface with improved aesthetics
|
139 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
|
167 |
)
|
168 |
# Update video player, clear transcription and audio input, and enable run button when YouTube URL is entered
|
169 |
youtube_input.change(
|
170 |
+
#fn=lambda url: (*embed_youtube(url), gr.update(interactive=bool(url))),
|
171 |
+
fn=embed_youtube ,
|
172 |
inputs=[youtube_input],
|
173 |
outputs=[video_player, result, audio_input, run_button]
|
174 |
)
|