Spaces:
Sleeping
Sleeping
Ubuntu
commited on
Commit
•
795f06e
1
Parent(s):
940d177
change embed logic
Browse files
app.py
CHANGED
@@ -159,15 +159,6 @@ def check_password(password):
|
|
159 |
def run_speech_translation(audio, source_lang, target_lang, youtube_url):
|
160 |
transcription, translated_text, audio_url = transcribe_and_speak(audio, source_lang, target_lang, youtube_url)
|
161 |
|
162 |
-
# Generate embedded video HTML if YouTube URL is provided
|
163 |
-
embedded_video = ""
|
164 |
-
if youtube_url:
|
165 |
-
try:
|
166 |
-
video_id = fetch_youtube_id(youtube_url)
|
167 |
-
embedded_video = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_id}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'
|
168 |
-
except Exception as e:
|
169 |
-
print(f"Error embedding video: {e}")
|
170 |
-
|
171 |
return transcription, translated_text, audio_url, embedded_video
|
172 |
|
173 |
with gr.Blocks() as demo:
|
@@ -213,4 +204,19 @@ with gr.Blocks() as demo:
|
|
213 |
outputs=[user_transcription_output, user_translation_output, user_audio_output, user_video_output]
|
214 |
)
|
215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
demo.launch(auth=(os.getenv("DEV_USER"), os.getenv("DEV_PWD")))
|
|
|
159 |
def run_speech_translation(audio, source_lang, target_lang, youtube_url):
|
160 |
transcription, translated_text, audio_url = transcribe_and_speak(audio, source_lang, target_lang, youtube_url)
|
161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
return transcription, translated_text, audio_url, embedded_video
|
163 |
|
164 |
with gr.Blocks() as demo:
|
|
|
204 |
outputs=[user_transcription_output, user_translation_output, user_audio_output, user_video_output]
|
205 |
)
|
206 |
|
207 |
+
def update_video_embed(youtube_url):
|
208 |
+
if youtube_url:
|
209 |
+
try:
|
210 |
+
video_id = fetch_youtube_id(youtube_url)
|
211 |
+
return f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_id}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'
|
212 |
+
except Exception as e:
|
213 |
+
print(f"Error embedding video: {e}")
|
214 |
+
return ""
|
215 |
+
|
216 |
+
user_youtube_url.change(
|
217 |
+
fn=update_video_embed,
|
218 |
+
inputs=[user_youtube_url],
|
219 |
+
outputs=[user_video_output]
|
220 |
+
)
|
221 |
+
|
222 |
demo.launch(auth=(os.getenv("DEV_USER"), os.getenv("DEV_PWD")))
|