File size: 635 Bytes
14247d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3d2e8a9
14247d9
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
import whisper
import tempfile
import os

model = whisper.load_model("base")


def video_to_text(video_file):
    temp_dir = tempfile.mkdtemp()
    video_path = os.path.join(temp_dir, "input_video.mp4")

    with open(video_path, 'wb') as f: 
        f.write(video_file.read())

    transcription = model.transcribe(video_path)
    os.remove(video_path)
    return transcription['text']


iface = gr.Interface(
    fn=video_to_text,
    inputs=gr.File(file_types=["video"]),
    outputs="text",
    title="Video to Text Transcription",
    description="Upload a video and get the transcribed text"
)

iface.launch()