AI_Text / app.py
adnaniqbal001's picture
Update app.py
b23c4a5 verified
raw
history blame contribute delete
813 Bytes
import whisper
import gradio as gr
import subprocess
import os
# Load Whisper model
model = whisper.load_model("large")
def transcribe_video(video_path):
try:
audio_path = "audio.wav"
subprocess.run(
["ffmpeg", "-i", video_path, "-ar", "16000", "-ac", "1", "-c:a", "pcm_s16le", audio_path],
check=True
)
result = model.transcribe(audio_path, task="transcribe", language="ur")
return result["text"]
except Exception as e:
return f"An error occurred: {e}"
# Gradio Interface
interface = gr.Interface(
fn=transcribe_video,
inputs=gr.Video(label="Upload your Urdu-speaking video"),
outputs=gr.Textbox(label="Transcribed Text"),
title="Urdu Video Transcription App"
)
if __name__ == "__main__":
interface.launch()