Video Subtitle Generator with Subtitle Embedded on Original Video using ASR and Speech-to-Text With OpenAI Whisper and Gradio
A step by step of Video Subtitle Generator with OpenAI Whisper and Gradio.
Install needed libs
! pip install git+https://github.com/openai/whisper.git -q
! pip install gradio -q
import gradio as gr
import os
import sys
import subprocess
#from moviepy.editor import VideoFileClip
import whisper
model = whisper.load_model("medium")
def video2mp3(video_file, output_ext="mp3"):
filename, ext = os.path.splitext(video_file)
subprocess.call(["ffmpeg", "-y", "-i", video_file, f"{filename}.{output_ext}"],
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT)
return f"{filename}.{output_ext}"
audio_file = "Speech_Martin_Luther_King-1963-08-26.mp3"
from IPython.display import Audio
Audio(audio_file)