Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -41,18 +41,32 @@ def download_video(url):
|
|
41 |
|
42 |
def main(url, clip_type, progress=gr.Progress()):
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
return output_video_file
|
57 |
|
58 |
|
|
|
41 |
|
42 |
def main(url, clip_type, progress=gr.Progress()):
|
43 |
|
44 |
+
if clip_type == "dub":
|
45 |
+
progress(0, desc="Starting")
|
46 |
+
video = download_video(url)
|
47 |
+
progress(5, desc="downloaded")
|
48 |
+
mp3_file, duration = extract_audio(video)
|
49 |
+
progress(10, desc="extract audio")
|
50 |
+
srt_list = transcribe(mp3_file)
|
51 |
+
progress(35, desc="transcribe")
|
52 |
+
subtitle_file = translate(srt_list)
|
53 |
+
progress(55, desc="translate")
|
54 |
+
output_video_file = video_edit(subtitle_file, video, input_audio= "audio.mp3")
|
55 |
+
progress(100, desc="finish")
|
56 |
+
os.remove(subtitle_file)
|
57 |
+
else:
|
58 |
+
progress(0, desc="Starting")
|
59 |
+
video = download_video(url)
|
60 |
+
progress(5, desc="downloaded")
|
61 |
+
mp3_file, duration = extract_audio(video)
|
62 |
+
progress(10, desc="extract audio")
|
63 |
+
srt_list = transcribe(mp3_file)
|
64 |
+
progress(35, desc="transcribe")
|
65 |
+
subtitle_file = translate(srt_list)
|
66 |
+
progress(55, desc="translate")
|
67 |
+
output_video_file = video_edit(subtitle_file, video, input_audio= "audio.mp3")
|
68 |
+
progress(100, desc="finish")
|
69 |
+
os.remove(subtitle_file)
|
70 |
return output_video_file
|
71 |
|
72 |
|