jeffh commited on
Commit
8312221
1 Parent(s): 765214e

basic gradio app, init!

Browse files
Files changed (2) hide show
  1. app.py +47 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import whisper
3
+ from pytube import YouTube
4
+
5
+ loaded_model = whisper.load_model("base")
6
+
7
+ def inference(link):
8
+ yt = YouTube(link)
9
+ path = yt.streams.filter(only_audio=True)[0].download(filename="audio.mp4")
10
+ options = whisper.DecodingOptions(without_timestamps=True)
11
+ results = loaded_model.transcribe(path)
12
+ return results['text']
13
+
14
+ def change_model(size):
15
+ loaded_model = whisper.load_model(size)
16
+
17
+ title="Youtube Whisperer"
18
+ description="Speech to text transcription of Youtube videos using OpenAI's Whisper"
19
+ block = gr.Blocks()
20
+
21
+ with block:
22
+ gr.HTML(
23
+ """
24
+ <div style="text-align: center; max-width: 500px; margin: 0 auto;">
25
+ <div>
26
+ <h1>Youtube Whisperer</h1>
27
+ </div>
28
+ <p style="margin-bottom: 10px; font-size: 94%">
29
+ Speech to text transcription of Youtube videos using OpenAI's Whisper
30
+ </p>
31
+ </div>
32
+ """
33
+ )
34
+ with gr.Group():
35
+ with gr.Box():
36
+ sz = gr.Dropdown(label="Model Size", choices=['base','small', 'medium', 'large'], value='base')
37
+ sz.change(change_model, inputs=[sz], outputs=[])
38
+ link = gr.Textbox(label="YouTube Link")
39
+ text = gr.Textbox(
40
+ label="Transcription",
41
+ placeholder="Transcription Output",
42
+ lines=5)
43
+ with gr.Row().style(mobile_collapse=False, equal_height=True):
44
+ btn = gr.Button("Transcribe")
45
+ btn.click(inference, inputs=[link], outputs=[text])
46
+
47
+ block.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ git+https://github.com/openai/whisper.git
3
+ pytube