SameerMahajan's picture
Create app.py
5984579 verified
raw
history blame contribute delete
458 Bytes
import gradio as gr
from transformers import pipeline
import numpy as np
def recognize_speech(audio):
print (type(audio))
transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
sr, y = audio
y = y.astype(np.float32)
y /= np.max(np.abs(y))
return transcriber({"sampling_rate": sr, "raw": y})["text"]
gr.close_all()
demo = gr.Interface(fn=recognize_speech, inputs="audio", outputs="text")
demo.launch()