import whisper import gradio as gr import subprocess # Load the Whisper model model = whisper.load_model("large") # Use "large" or "large-v2" for best results def transcribe_video(video_path): # Extract audio from the uploaded video audio_path = "audio.wav" subprocess.run(["ffmpeg", "-i", video_path, "-ar", "16000", "-ac", "1", "-c:a", "pcm_s16le", audio_path]) # Transcribe the audio in Urdu result = model.transcribe(audio_path, task="transcribe", language="ur") # Return the transcribed text return result["text"] # Create the 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", description="Upload a video file in Urdu, and this app will transcribe the speech into text using Whisper.", ) # Launch the app if __name__ == "__main__": interface.launch()