Spaces:
Runtime error
Runtime error
File size: 2,358 Bytes
4e9f8f3 5f7dd87 17bf4d1 a43a5cc 4e9f8f3 dbbce8c 4e9f8f3 0b37b80 ce29b18 e0580a1 1dd6060 e0580a1 b9c2a95 4e9f8f3 5edc951 b9c2a95 5edc951 4e9f8f3 5edc951 4e9f8f3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
import os
import gradio as gr
import yt_dlp
import uuid
import whisper_diarization_main
#os.system("pip install Cython")
def dl(inp,img=None):
uid=uuid.uuid4()
fps="Error"
out = None
out_file=[]
if img == None and inp !="":
try:
inp_out=inp.replace("https://","")
inp_out=inp_out.replace("/","_").replace(".","_").replace("=","_").replace("?","_")
#os.system(f'yt-dlp "{inp}" --trim-filenames 160 -o "{uid}/{inp_out}.mp4" -S res,mp4 --recode mp4')
#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}"')
os.system(f'yt-dlp -x "{inp}" -o "{uid}/{inp_out}"')
#f = open(f"{uid}/{inp_out}.en.srt")
os.system(f'ffmpeg -i "{uid}/{inp_out}.opus" "output.mp3"')
##ft=f.readlines()
##line_fin=""
##line_out=""
##for line in ft:
## if "<" in line:
## line_out = line.split(">",1)[1].split("<",1)[0]
## else:
## line_out = line
## if not line.strip("\n").isnumeric():
## line_fin+=line_out
#print(ft)
#out = f"{uid}/{inp_out}.mp4"
#capture = cv2.VideoCapture(out)
#fps = capture.get(cv2.CAP_PROP_FPS)
#capture.release()
out="output.mp3"
##out=f'{line_fin}'
except Exception as e:
print(e)
out = None
elif img !=None and inp == "":
capture = cv2.VideoCapture(img)
fps = capture.get(cv2.CAP_PROP_FPS)
capture.release()
out = f"{img}"
return out
def diarize_aud(file_name):
print(file_name)
#file_name=file_name.strip(".mp3")
#print(file_name)
os.system(f"python whisper_diarization_main/diarize.py -a output.mp3")
with open(f"output.txt","r") as f:
lines=f.readlines()
line_out=""
for line in lines:
line_out+=line
return line_out
with gr.Blocks() as app:
inp_url=gr.Textbox()
btn=gr.Button()
btn2=gr.Button("diarize")
outp_aud=gr.Audio(type='filepath')
outp_diary=gr.Textbox()
btn.click(dl,inp_url,outp_aud)
btn2.click(diarize_aud,outp_aud,outp_diary)
app.launch() |