Spaces:
Runtime error
Runtime error
File size: 825 Bytes
9212547 e824905 9212547 b931283 4034654 b931283 e824905 4034654 e824905 24e0e26 4034654 2d12b2a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
import gradio as gr
from transformers import pipeline
MODEL_NAME = "openai/whisper-large-v3"
BATCH_SIZE = 8
asr = pipeline(
task="automatic-speech-recognition",
model=MODEL_NAME,
)
def transcribe(filepath):
if filepath is None:
gr.Warning("No audio found, please retry.")
return ""
output = asr(
filepath,
max_new_tokens=256,
chunk_length_s=30,
batch_size=8,
)
return output["text"]
mic_transcribe = gr.Interface(
fn=transcribe,
inputs=gr.Audio(sources="microphone",
type="filepath"),
outputs=gr.Textbox(label="Transcription",
lines=3),
allow_flagging="never")
demo = gr.Blocks()
with demo:
gr.TabbedInterface(
[mic_transcribe],
["Transcribe Microphone"],
)
demo.launch() |