aka7774 commited on
Commit
c0c1d35
1 Parent(s): c8ca022

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import whisper
3
+
4
+ model_size = 'small'
5
+ model = whisper.load_model(model_size)
6
+
7
+ def speech_to_text(tmp_filename, _model_size):
8
+ if model_size != _model_size:
9
+ model_size = _model_size
10
+ model = whisper.load_model(model_size)
11
+
12
+ result = model.transcribe(tmp_filename)
13
+
14
+ return result["text"]
15
+
16
+ gr.Interface(
17
+ fn=speech_to_text,
18
+ inputs=[
19
+ gr.Audio(source="microphone", type="filepath"),
20
+ gr.Dropdown(choices=["tiny", "base", "small", "medium", "large"]),
21
+ ],
22
+ outputs="text").launch()