vitaliy-sharandin
commited on
Commit
•
c00a37b
1
Parent(s):
b3c41ef
Update app.py
Browse files
app.py
CHANGED
@@ -259,6 +259,9 @@ def video_translation(video_path, target_language, speaker_model, hf_token, deep
|
|
259 |
|
260 |
return video_with_dubbing
|
261 |
|
|
|
|
|
|
|
262 |
def translate_video(video_path, youtube_link, target_language, speaker_model):
|
263 |
try:
|
264 |
if not video_path and not youtube_link:
|
@@ -273,35 +276,34 @@ def translate_video(video_path, youtube_link, target_language, speaker_model):
|
|
273 |
raise e
|
274 |
return translation_limit_info, gr.components.Video(dubbed_video)
|
275 |
|
276 |
-
|
277 |
def translation_limit():
|
278 |
translator = deepl.Translator(DEEPL_TOKEN)
|
279 |
usage = translator.get_usage()
|
280 |
if usage.character.valid:
|
281 |
characters_used = usage.character.count
|
282 |
-
minutes_used =
|
283 |
-
max_minutes =
|
284 |
percent_used = (minutes_used / max_minutes) * 100
|
285 |
|
286 |
# Formatting the output for hours and minutes
|
287 |
-
used_time_str = f"{minutes_used} min used"
|
288 |
-
max_time_str = f"{max_minutes} min total"
|
289 |
if minutes_used >= 60:
|
290 |
-
hours_used = minutes_used // 60
|
291 |
-
minutes_used = minutes_used % 60
|
292 |
used_time_str = f"{hours_used} hrs, {minutes_used} min used"
|
293 |
if max_minutes >= 60:
|
294 |
-
hours_max = max_minutes // 60
|
295 |
-
remaining_minutes_max = max_minutes % 60
|
296 |
max_time_str = f"{hours_max} hrs, {remaining_minutes_max} min total"
|
297 |
|
298 |
progress_bar_html = (
|
299 |
-
"<div style='width: 100%; background-color: #
|
300 |
-
"line-height: 2em; font-
|
301 |
-
"<div style='position: absolute; width: 100%; left: 0; top: 0;'>"
|
302 |
f"{used_time_str} / {max_time_str}"
|
303 |
"</div>"
|
304 |
-
f"<div style='height: 2em; background-color: #4caf50; width: {percent_used}%;'>"
|
305 |
"</div>"
|
306 |
"</div>"
|
307 |
)
|
@@ -312,8 +314,6 @@ def translation_limit():
|
|
312 |
def clear_inputs():
|
313 |
return None, "", None, None
|
314 |
|
315 |
-
|
316 |
-
|
317 |
css = """
|
318 |
.column-frame {
|
319 |
border: 2px solid #AAA;
|
|
|
259 |
|
260 |
return video_with_dubbing
|
261 |
|
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:
|
|
|
276 |
raise e
|
277 |
return translation_limit_info, gr.components.Video(dubbed_video)
|
278 |
|
|
|
279 |
def translation_limit():
|
280 |
translator = deepl.Translator(DEEPL_TOKEN)
|
281 |
usage = translator.get_usage()
|
282 |
if usage.character.valid:
|
283 |
characters_used = usage.character.count
|
284 |
+
minutes_used = characters_used / 750
|
285 |
+
max_minutes = usage.character.limit / 750
|
286 |
percent_used = (minutes_used / max_minutes) * 100
|
287 |
|
288 |
# Formatting the output for hours and minutes
|
289 |
+
used_time_str = f"{int(minutes_used)} min used"
|
290 |
+
max_time_str = f"{int(max_minutes)} min total"
|
291 |
if minutes_used >= 60:
|
292 |
+
hours_used = int(minutes_used // 60)
|
293 |
+
minutes_used = int(minutes_used % 60)
|
294 |
used_time_str = f"{hours_used} hrs, {minutes_used} min used"
|
295 |
if max_minutes >= 60:
|
296 |
+
hours_max = int(max_minutes // 60)
|
297 |
+
remaining_minutes_max = int(max_minutes % 60)
|
298 |
max_time_str = f"{hours_max} hrs, {remaining_minutes_max} min total"
|
299 |
|
300 |
progress_bar_html = (
|
301 |
+
"<div style='width: 100%; background-color: #adb5bd; position: relative; text-align: center; "
|
302 |
+
"line-height: 2em; color: white; font-weight: bold;'>"
|
303 |
+
"<div style='position: absolute; width: 100%; left: 0; top: 0; z-index: 1;'>"
|
304 |
f"{used_time_str} / {max_time_str}"
|
305 |
"</div>"
|
306 |
+
f"<div style='height: 2em; background-color: #4caf50; width: {percent_used}%; z-index: 0;'>"
|
307 |
"</div>"
|
308 |
"</div>"
|
309 |
)
|
|
|
314 |
def clear_inputs():
|
315 |
return None, "", None, None
|
316 |
|
|
|
|
|
317 |
css = """
|
318 |
.column-frame {
|
319 |
border: 2px solid #AAA;
|