nitiksh's picture
Update app.py
6a031e6 verified
raw
history blame contribute delete
829 Bytes
import gradio as gr
import subprocess
import os
def videoxsub(vid):
getAudio(vid)
getSubs()
# Return the video, subtitle content, and a path to the subtitle file for download
with open("audio.vtt", "r") as file:
subtitle_content = file.read()
return [vid, subtitle_content, "audio.vtt"]
def getAudio(vid):
if os.path.exists("audio.mp3"):
os.remove("audio.mp3")
commands_list = ["ffmpeg", "-i", vid, "audio.mp3"]
subprocess.run(commands_list)
def getSubs():
command_list = ["whisper", "audio.mp3", "-f", "vtt", "--fp16", "False"]
subprocess.run(command_list)
demo = gr.Interface(
fn=videoxsub,
inputs="video",
outputs=[
gr.Video(label="Video"),
gr.Textbox(label="Subtitles"),
gr.File(label="Download Subtitles")
]
)
demo.launch()