Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
import yt_dlp
|
4 |
+
|
5 |
+
def dl(inp,img=None):
|
6 |
+
uid=uuid.uuid4()
|
7 |
+
fps="Error"
|
8 |
+
out = None
|
9 |
+
out_file=[]
|
10 |
+
if img == None and inp !="":
|
11 |
+
try:
|
12 |
+
inp_out=inp.replace("https://","")
|
13 |
+
inp_out=inp_out.replace("/","_").replace(".","_").replace("=","_").replace("?","_")
|
14 |
+
|
15 |
+
#os.system(f'yt-dlp "{inp}" --trim-filenames 160 -o "{uid}/{inp_out}.mp4" -S res,mp4 --recode mp4')
|
16 |
+
#os.system(f'yt-dlp --skip-download --write-subs --write-auto-subs --sub-lang en --sub-format ttml --convert-subs srt "{inp}" -o "{uid}/{inp_out}"')
|
17 |
+
os.system(f'yt-dlp -x "{inp}" -o "{uid}/{inp_out}"')
|
18 |
+
#f = open(f"{uid}/{inp_out}.en.srt")
|
19 |
+
ffmpeg -i f"{uid}/{inp_out}.opus" "output.mp3"
|
20 |
+
##ft=f.readlines()
|
21 |
+
##line_fin=""
|
22 |
+
##line_out=""
|
23 |
+
##for line in ft:
|
24 |
+
## if "<" in line:
|
25 |
+
## line_out = line.split(">",1)[1].split("<",1)[0]
|
26 |
+
## else:
|
27 |
+
## line_out = line
|
28 |
+
## if not line.strip("\n").isnumeric():
|
29 |
+
## line_fin+=line_out
|
30 |
+
#print(ft)
|
31 |
+
#out = f"{uid}/{inp_out}.mp4"
|
32 |
+
#capture = cv2.VideoCapture(out)
|
33 |
+
#fps = capture.get(cv2.CAP_PROP_FPS)
|
34 |
+
#capture.release()
|
35 |
+
out="output.mp3"
|
36 |
+
##out=f'{line_fin}'
|
37 |
+
except Exception as e:
|
38 |
+
print(e)
|
39 |
+
out = None
|
40 |
+
elif img !=None and inp == "":
|
41 |
+
capture = cv2.VideoCapture(img)
|
42 |
+
fps = capture.get(cv2.CAP_PROP_FPS)
|
43 |
+
capture.release()
|
44 |
+
out = f"{img}"
|
45 |
+
return out
|
46 |
+
|
47 |
+
|
48 |
+
os.system(f"python diarize.py -a {AUDIO_FILE_NAME}")
|
49 |
+
|
50 |
+
|
51 |
+
with gr.Blocks() as app:
|
52 |
+
inp_url=gr.Textbox()
|
53 |
+
btn=gr.Button()
|
54 |
+
outp_aud=gr.Audio()
|
55 |
+
btn.click(dl,inp_url,outp_aud)
|
56 |
+
app.launch()
|