vitaliy-sharandin
commited on
Commit
•
74e9760
1
Parent(s):
3b6f758
Update app.py
Browse files
app.py
CHANGED
@@ -308,15 +308,15 @@ def translate_video(video_path, youtube_link, target_language, speaker_model):
|
|
308 |
try:
|
309 |
if not video_path and not youtube_link:
|
310 |
gr.Warning("You should either upload video or input a YouTube link")
|
311 |
-
return
|
312 |
if youtube_link:
|
313 |
video_path = download_youtube_video(youtube_link)
|
314 |
if video_path is None:
|
315 |
gr.Warning("Video input did not process well, try again")
|
316 |
-
return
|
317 |
-
|
318 |
limit_info = translation_limit()
|
319 |
-
return
|
320 |
except Exception as e:
|
321 |
print(f"An error occurred: {e}")
|
322 |
raise e
|
@@ -340,7 +340,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
340 |
with gr.Row():
|
341 |
with gr.Column(elem_classes=["column-frame"]):
|
342 |
gr.Markdown("<h2 style='text-align: center;'>Inputs</h3>")
|
343 |
-
translation_limit_info = gr.
|
344 |
video = gr.Video(label="Upload a video file")
|
345 |
gr.Markdown("<h3 style='text-align: center;'>OR</h3>")
|
346 |
youtube_link = gr.Textbox(label="Paste YouTube link")
|
|
|
308 |
try:
|
309 |
if not video_path and not youtube_link:
|
310 |
gr.Warning("You should either upload video or input a YouTube link")
|
311 |
+
return translation_limit(), None
|
312 |
if youtube_link:
|
313 |
video_path = download_youtube_video(youtube_link)
|
314 |
if video_path is None:
|
315 |
gr.Warning("Video input did not process well, try again")
|
316 |
+
return translation_limit(), None
|
317 |
+
dubbed_video_path = video_translation(video_path, target_language, speaker_model, HF_TOKEN, DEEPL_TOKEN)
|
318 |
limit_info = translation_limit()
|
319 |
+
return limit_info, dubbed_video_path
|
320 |
except Exception as e:
|
321 |
print(f"An error occurred: {e}")
|
322 |
raise e
|
|
|
340 |
with gr.Row():
|
341 |
with gr.Column(elem_classes=["column-frame"]):
|
342 |
gr.Markdown("<h2 style='text-align: center;'>Inputs</h3>")
|
343 |
+
translation_limit_info = gr.HTML(value=translation_limit())
|
344 |
video = gr.Video(label="Upload a video file")
|
345 |
gr.Markdown("<h3 style='text-align: center;'>OR</h3>")
|
346 |
youtube_link = gr.Textbox(label="Paste YouTube link")
|