SameerMahajan commited on
Commit
5984579
1 Parent(s): 556bfad

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ import numpy as np
4
+
5
+ def recognize_speech(audio):
6
+ print (type(audio))
7
+ transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
8
+ sr, y = audio
9
+ y = y.astype(np.float32)
10
+ y /= np.max(np.abs(y))
11
+ return transcriber({"sampling_rate": sr, "raw": y})["text"]
12
+
13
+ gr.close_all()
14
+ demo = gr.Interface(fn=recognize_speech, inputs="audio", outputs="text")
15
+ demo.launch()