Thong Nguyen commited on
Commit
14247d9
1 Parent(s): d2e7b10

Deploy application

Browse files
Files changed (2) hide show
  1. app.py +29 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import whisper
3
+ import tempfile
4
+ import os
5
+
6
+ model = whisper.load_model("base")
7
+
8
+
9
+ def video_to_text(video_file):
10
+ temp_dir = tempfile.mkdtemp()
11
+ video_path = os.path.join(temp_dir, "input_video.mp4")
12
+
13
+ with open(video_path, 'wb') as f:
14
+ f.write(video_file.read())
15
+
16
+ transcription = model.transcribe(video_path)
17
+ os.remove(video_path)
18
+ return transcription['text']
19
+
20
+
21
+ iface = gr.Interface(
22
+ fn=video_to_text,
23
+ inputs=gr.Video(type="file"),
24
+ outputs="text",
25
+ title="Video to Text Transcription",
26
+ description="Upload a video and get the transcribed text"
27
+ )
28
+
29
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ whisper
3
+ ffmpeg-python