Spaces:
Sleeping
Sleeping
# app.py | |
import gradio as gr | |
import torch | |
from transformers import pipeline | |
# Load a fast automatic speech recognition pipeline | |
asr_pipeline = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h") | |
def transcribe_audio(audio): | |
if audio is None: | |
return "No audio input" | |
text = asr_pipeline(audio)["text"] | |
return text | |
# Gradio Interface | |
iface = gr.Interface( | |
fn=transcribe_audio, | |
inputs=gr.Audio(sources=["microphone"], type="filepath"), | |
outputs=gr.Textbox(label="Recognized Text"), | |
live=True, | |
title="Real-time Voice to Text (Fast Version)", | |
description="Speak into your microphone and get instant transcription!", | |
) | |
if __name__ == "__main__": | |
iface.launch() |