dodoya1's picture
Update app.py
619d335
raw
history blame
No virus
861 Bytes
import gradio as gr
import whisper
import os
model = whisper.load_model("medium")
# main processing
def main(URL):
video_path = youtube_dl(URL)
text = transcript(video_path)
return text
# Transcribe text using Whisper
def transcript(video_path):
result = model.transcribe(video_path)
return result["text"]
# Download the video
def youtube_dl(URL):
# Download the video
os.system(f"yt-dlp -f best -v {URL} -o target.mp4")
# Path of downloaded video
video_path = os.path.join(os.path.dirname(__file__), "target.mp4")
# Check if the video is downloaded successfully
if os.path.exists(video_path):
return video_path
else:
raise ValueError("Video download failed")
demo = gr.Interface(fn = main,
inputs = "text", outputs = "text")
if __name__ == "__main__":
demo.launch()