transformers_js_py
from transformers_js import import_transformers_js
import gradio as gr
import numpy as np
transformers = await import_transformers_js()
pipeline = transformers.pipeline
pipe = await pipeline("automatic-speech-recognition",'Xenova/whisper-small')
async def transcribe(audio):
sr, y = audio
y = y.astype(np.float32)
y /= np.max(np.abs(y))
return pipe({"sampling_rate": sr, "raw": y})["text"]
demo = gr.Interface(
transcribe,
gr.Audio(source="microphone"),
"text",
theme=gr.themes.Soft(),)
demo.launch()