Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -24,8 +24,20 @@ def extract_audio(input_video_name):
|
|
24 |
print("Audio extraction successful!")
|
25 |
return mp3_file, duration
|
26 |
|
27 |
-
def
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
mp3_file, duration = extract_audio(video)
|
30 |
srt_list = transcribe(mp3_file)
|
31 |
subtitle_file = translate(srt_list)
|
@@ -36,7 +48,7 @@ def main(video, clip_type):
|
|
36 |
with gr.Blocks() as demo:
|
37 |
gr.Markdown("Start typing below and then click **Run** to see the output.")
|
38 |
with gr.Column():
|
39 |
-
video_file_input = gr.
|
40 |
clip_type = gr.Dropdown(["auto edit", "default"], label="Clip Type")
|
41 |
btn = gr.Button("create")
|
42 |
video_file_output = gr.Video(label="result: ")
|
|
|
24 |
print("Audio extraction successful!")
|
25 |
return mp3_file, duration
|
26 |
|
27 |
+
def download_video(url):
|
28 |
+
|
29 |
+
response = requests.get(url, stream=True)
|
30 |
+
response.raise_for_status()
|
31 |
+
with open("video.mp4", 'wb') as file:
|
32 |
+
for chunk in response.iter_content(chunk_size=8192):
|
33 |
+
if chunk:
|
34 |
+
file.write(chunk)
|
35 |
+
print(f"Downloaded successfully")
|
36 |
+
return "video.mp4"
|
37 |
+
|
38 |
+
def main(url, clip_type):
|
39 |
+
|
40 |
+
video = download_video(url)
|
41 |
mp3_file, duration = extract_audio(video)
|
42 |
srt_list = transcribe(mp3_file)
|
43 |
subtitle_file = translate(srt_list)
|
|
|
48 |
with gr.Blocks() as demo:
|
49 |
gr.Markdown("Start typing below and then click **Run** to see the output.")
|
50 |
with gr.Column():
|
51 |
+
video_file_input = gr.Text(label="Upload Video url")
|
52 |
clip_type = gr.Dropdown(["auto edit", "default"], label="Clip Type")
|
53 |
btn = gr.Button("create")
|
54 |
video_file_output = gr.Video(label="result: ")
|