dodoya1 commited on
Commit
c196faa
1 Parent(s): d7ece34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -6
app.py CHANGED
@@ -2,16 +2,17 @@ import gradio as gr
2
  import whisper
3
  import os
4
 
5
- model = whisper.load_model("tiny")
6
 
7
  # main processing
8
- def main(URL):
9
  video_path = youtube_dl(URL)
10
- text = transcript(video_path)
11
  return text
12
 
13
  # Transcribe text using Whisper
14
- def transcript(video_path):
 
15
  result = model.transcribe(video_path)
16
  return result["text"]
17
 
@@ -23,8 +24,28 @@ def youtube_dl(URL):
23
  video_path = os.path.join(os.path.dirname(__file__), "target.mp4")
24
  return video_path
25
 
26
- demo = gr.Interface(fn = main,
27
- inputs = "text", outputs = "text")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  if __name__ == "__main__":
30
  demo.launch()
 
2
  import whisper
3
  import os
4
 
5
+ model_size = list(whisper._MODELS.keys())
6
 
7
  # main processing
8
+ def main(URL, model_size):
9
  video_path = youtube_dl(URL)
10
+ text = transcript(video_path, model_size)
11
  return text
12
 
13
  # Transcribe text using Whisper
14
+ def transcript(video_path, model_size):
15
+ model = whisper.load_model(model_size)
16
  result = model.transcribe(video_path)
17
  return result["text"]
18
 
 
24
  video_path = os.path.join(os.path.dirname(__file__), "target.mp4")
25
  return video_path
26
 
27
+ with gr.Blocks() as demo:
28
+
29
+ with gr.Row():
30
+
31
+ with gr.Column():
32
+
33
+ with gr.Row():
34
+ url = gr.Textbox(placeholder = 'Youtube video URL', label = 'URL')
35
+
36
+ with gr.Row():
37
+ model_size = gr.Dropdown(choices = model_size, value = 'tiny', label = "Model")
38
+
39
+ with gr.Row():
40
+ transcribe_btn = gr.Button('Transcribe')
41
+
42
+ with gr.Column():
43
+ outputs = gr.Textbox(placeholder = 'Transcription of the video', label = 'Transcription')
44
+
45
+ transcribe_btn.click(fn = main,
46
+ inputs = [url, model_size],
47
+ outputs = outputs
48
+ )
49
 
50
  if __name__ == "__main__":
51
  demo.launch()