Spaces:
Running
on
Zero
Running
on
Zero
alex
commited on
Commit
·
bbee8a4
1
Parent(s):
2171623
progress bar
Browse files
app.py
CHANGED
|
@@ -559,29 +559,29 @@ def build_srt(segments: List[Dict], audio_wav: str, out_srt_path: str):
|
|
| 559 |
with open(out_srt_path, "w", encoding="utf-8") as f:
|
| 560 |
f.write(srt.compose(subtitles))
|
| 561 |
|
| 562 |
-
def translate_video(video_file, duration, session_id = None):
|
| 563 |
|
| 564 |
if video_file is None:
|
| 565 |
raise gr.Error("Please upload a clip.")
|
| 566 |
|
| 567 |
-
return process_video(video_file, False, duration, session_id)
|
| 568 |
|
| 569 |
-
def translate_lipsync_video(video_file, duration, session_id = None):
|
| 570 |
|
| 571 |
if video_file is None:
|
| 572 |
raise gr.Error("Please upload a clip.")
|
| 573 |
|
| 574 |
-
return process_video(video_file, True, duration, session_id)
|
| 575 |
|
| 576 |
|
| 577 |
-
def run_example(video_file, allow_lipsync, duration, session_id = None):
|
| 578 |
|
| 579 |
with timer("processed"):
|
| 580 |
-
result = process_video(video_file, allow_lipsync, duration, session_id)
|
| 581 |
|
| 582 |
return result
|
| 583 |
|
| 584 |
-
def get_duration(video_file, allow_lipsync, duration, session_id):
|
| 585 |
|
| 586 |
if allow_lipsync:
|
| 587 |
if duration <= 3:
|
|
@@ -598,7 +598,7 @@ def get_duration(video_file, allow_lipsync, duration, session_id):
|
|
| 598 |
return 40
|
| 599 |
|
| 600 |
@spaces.GPU(duration=get_duration)
|
| 601 |
-
def process_video(video_file, allow_lipsync, duration, session_id = None):
|
| 602 |
"""
|
| 603 |
Gradio callback:
|
| 604 |
- video_file: temp file object/path from Gradio
|
|
|
|
| 559 |
with open(out_srt_path, "w", encoding="utf-8") as f:
|
| 560 |
f.write(srt.compose(subtitles))
|
| 561 |
|
| 562 |
+
def translate_video(video_file, duration, session_id = None, progress=gr.Progress(track_tqdm=True)):
|
| 563 |
|
| 564 |
if video_file is None:
|
| 565 |
raise gr.Error("Please upload a clip.")
|
| 566 |
|
| 567 |
+
return process_video(video_file, False, duration, session_id, progress)
|
| 568 |
|
| 569 |
+
def translate_lipsync_video(video_file, duration, session_id = None, progress=gr.Progress(track_tqdm=True)):
|
| 570 |
|
| 571 |
if video_file is None:
|
| 572 |
raise gr.Error("Please upload a clip.")
|
| 573 |
|
| 574 |
+
return process_video(video_file, True, duration, session_id, progress)
|
| 575 |
|
| 576 |
|
| 577 |
+
def run_example(video_file, allow_lipsync, duration, session_id = None, progress=gr.Progress(track_tqdm=True)):
|
| 578 |
|
| 579 |
with timer("processed"):
|
| 580 |
+
result = process_video(video_file, allow_lipsync, duration, session_id, progress)
|
| 581 |
|
| 582 |
return result
|
| 583 |
|
| 584 |
+
def get_duration(video_file, allow_lipsync, duration, session_id, progress):
|
| 585 |
|
| 586 |
if allow_lipsync:
|
| 587 |
if duration <= 3:
|
|
|
|
| 598 |
return 40
|
| 599 |
|
| 600 |
@spaces.GPU(duration=get_duration)
|
| 601 |
+
def process_video(video_file, allow_lipsync, duration, session_id = None, progress=gr.Progress(track_tqdm=True)):
|
| 602 |
"""
|
| 603 |
Gradio callback:
|
| 604 |
- video_file: temp file object/path from Gradio
|