azamat commited on
Commit
ef95f06
1 Parent(s): deebdf8
Files changed (2) hide show
  1. app.py +24 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from faster_whisper import WhisperModel
3
+
4
+ device = "cpu"
5
+ model_size = "tiny"
6
+ compute_type = "int8"
7
+
8
+ model = WhisperModel(model_size, device=device, compute_type=compute_type)
9
+
10
+ def transcribe(audio):
11
+ segments, _ = model.transcribe(audio, beam_size=5)
12
+ return "".join([segment.text for segment in segments])
13
+
14
+ gr.Interface(
15
+ title = 'Fast Whisper for Speech Recognition',
16
+ description = 'This is a tiny version running on CPU with int8 compute type due to limited resources. These choices can slightly reduce accuracy.',
17
+ fn=transcribe,
18
+ inputs=[
19
+ gr.inputs.Audio(source="microphone", type="filepath")
20
+ ],
21
+ outputs=[
22
+ "textbox"
23
+ ]
24
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ faster-whisper