File size: 458 Bytes
5984579
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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()