import gradio as gr from transformers import pipeline # Load Wav2Vec 2.0 speech recognition model asr = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h") # Function to process audio and return transcribed text def transcribe(audio): if audio is None: return "No audio provided." return asr(audio)["text"] # Gradio Interface interface = gr.Interface( fn=transcribe, inputs=gr.Audio(type="filepath", label="Upload or Record Audio"), outputs=gr.Textbox(label="Transcribed Text"), title="🎤 Wav2Vec 2.0 - Speech to Text", description="Upload or record an audio file and get the transcribed text using Facebook's Wav2Vec 2.0." ) interface.launch()