Spaces:
Runtime error
Runtime error
download url method
Browse files- requirements.txt +2 -1
- run.py +12 -4
requirements.txt
CHANGED
@@ -20,4 +20,5 @@ gradio==4.1.2
|
|
20 |
ffmpy
|
21 |
flask_ngrok2
|
22 |
flask_ngrok
|
23 |
-
opencv-python
|
|
|
|
20 |
ffmpy
|
21 |
flask_ngrok2
|
22 |
flask_ngrok
|
23 |
+
opencv-python
|
24 |
+
requests
|
run.py
CHANGED
@@ -1,11 +1,19 @@
|
|
1 |
import os
|
2 |
import sys
|
3 |
-
|
4 |
|
5 |
from main import call_wav2lip, call_gfpgan, merge
|
6 |
|
7 |
root_dir = '/content/jobs'
|
8 |
-
os.makedirs(root_dir,exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
|
11 |
def main(job_id, video_url, audio_url):
|
@@ -15,14 +23,14 @@ def main(job_id, video_url, audio_url):
|
|
15 |
if video_url.startswith('http'):
|
16 |
video_file = os.path.basename(video_url)
|
17 |
video_path = os.path.join(job_path, video_file)
|
18 |
-
|
19 |
else:
|
20 |
video_path = video_url
|
21 |
|
22 |
if audio_url.startswith('http'):
|
23 |
audio_file = os.path.basename(audio_url)
|
24 |
audio_path = os.path.join(job_path, audio_file)
|
25 |
-
|
26 |
else:
|
27 |
audio_path = audio_url
|
28 |
|
|
|
1 |
import os
|
2 |
import sys
|
3 |
+
import requests
|
4 |
|
5 |
from main import call_wav2lip, call_gfpgan, merge
|
6 |
|
7 |
root_dir = '/content/jobs'
|
8 |
+
os.makedirs(root_dir, exist_ok=True)
|
9 |
+
|
10 |
+
|
11 |
+
def download_file(url, local_filename):
|
12 |
+
response = requests.get(url, stream=True)
|
13 |
+
with open(local_filename, 'wb') as file:
|
14 |
+
for chunk in response.iter_content(chunk_size=8192):
|
15 |
+
if chunk:
|
16 |
+
file.write(chunk)
|
17 |
|
18 |
|
19 |
def main(job_id, video_url, audio_url):
|
|
|
23 |
if video_url.startswith('http'):
|
24 |
video_file = os.path.basename(video_url)
|
25 |
video_path = os.path.join(job_path, video_file)
|
26 |
+
download_file(video_url, video_path)
|
27 |
else:
|
28 |
video_path = video_url
|
29 |
|
30 |
if audio_url.startswith('http'):
|
31 |
audio_file = os.path.basename(audio_url)
|
32 |
audio_path = os.path.join(job_path, audio_file)
|
33 |
+
download_file(audio_url, audio_path)
|
34 |
else:
|
35 |
audio_path = audio_url
|
36 |
|