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()