vitaliy-sharandin
commited on
Commit
•
c981ef0
1
Parent(s):
b4e21e9
Update app.py
Browse files
app.py
CHANGED
@@ -262,20 +262,6 @@ def video_translation(video_path, target_language, speaker_model, hf_token, deep
|
|
262 |
|
263 |
|
264 |
|
265 |
-
def translate_video(video_path, youtube_link, target_language, speaker_model):
|
266 |
-
try:
|
267 |
-
if not video_path and not youtube_link:
|
268 |
-
gr.Warning("You should either upload video or input a YouTube link")
|
269 |
-
return None
|
270 |
-
if youtube_link:
|
271 |
-
video_path = download_youtube_video(youtube_link)
|
272 |
-
dubbed_video = video_translation(video_path, target_language, speaker_model, HF_TOKEN, DEEPL_TOKEN)
|
273 |
-
translation_limit_info = translation_limit()
|
274 |
-
except Exception as e:
|
275 |
-
print(f"An error occurred: {e}")
|
276 |
-
raise e
|
277 |
-
return gr.Markdown(translation_limit_info), gr.components.Video(dubbed_video)
|
278 |
-
|
279 |
def translation_limit():
|
280 |
translator = deepl.Translator(DEEPL_TOKEN)
|
281 |
usage = translator.get_usage()
|
@@ -311,9 +297,25 @@ def translation_limit():
|
|
311 |
else:
|
312 |
return "<div style='color: red; text-align: center;'>Translation limit is reached</div>"
|
313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
def clear_inputs():
|
315 |
return None, "", None, None
|
316 |
|
|
|
|
|
317 |
css = """
|
318 |
.column-frame {
|
319 |
border: 2px solid #AAA;
|
|
|
262 |
|
263 |
|
264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
def translation_limit():
|
266 |
translator = deepl.Translator(DEEPL_TOKEN)
|
267 |
usage = translator.get_usage()
|
|
|
297 |
else:
|
298 |
return "<div style='color: red; text-align: center;'>Translation limit is reached</div>"
|
299 |
|
300 |
+
def translate_video(video_path, youtube_link, target_language, speaker_model):
|
301 |
+
try:
|
302 |
+
if not video_path and not youtube_link:
|
303 |
+
gr.Warning("You should either upload video or input a YouTube link")
|
304 |
+
return None
|
305 |
+
if youtube_link:
|
306 |
+
video_path = download_youtube_video(youtube_link)
|
307 |
+
dubbed_video = video_translation(video_path, target_language, speaker_model, HF_TOKEN, DEEPL_TOKEN)
|
308 |
+
translation_limit_info = translation_limit()
|
309 |
+
except Exception as e:
|
310 |
+
print(f"An error occurred: {e}")
|
311 |
+
raise e
|
312 |
+
return gr.Markdown(translation_limit_info), gr.components.Video(dubbed_video)
|
313 |
+
|
314 |
def clear_inputs():
|
315 |
return None, "", None, None
|
316 |
|
317 |
+
|
318 |
+
|
319 |
css = """
|
320 |
.column-frame {
|
321 |
border: 2px solid #AAA;
|