AkashMnd commited on
Commit
0896895
·
1 Parent(s): c3260e5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import soundfile as sf
3
+ from faster_whisper import WhisperModel
4
+
5
+ model = WhisperModel("tiny.en", device="cpu", compute_type="int8")
6
+
7
+ def transcribe_audio(audio):
8
+ sr, data = audio
9
+ temp_file = "temp.wav"
10
+ sf.write(temp_file, data, sr, format='wav')
11
+ segments, info = model.transcribe(temp_file)
12
+ result = ""
13
+ for segment in segments:
14
+ result += "[%.2fs -> %.2fs] %s\n" % (segment.start, segment.end, segment.text)
15
+ return result
16
+
17
+ iface = gr.Interface(
18
+ fn=transcribe_audio,
19
+ inputs=["microphone"],
20
+ outputs=gr.Textbox(),
21
+ title="Team UNDERGOD SIF Hackathon Audio to Text Demo (Using Faster Whisper Tiny int 8 CPU)",
22
+ description="This Demo Shows our state of the art solution for Psuedo real-time audio transcription (Only English Accepted)"
23
+ )
24
+
25
+ iface.launch(debug=True)