Subbu1304's picture
Update app.py
5656ca3 verified
raw
history blame contribute delete
709 Bytes
import gradio as gr
from transformers import pipeline
# Load the Hugging Face ASR model
asr_pipeline = pipeline("automatic-speech-recognition", model="openai/whisper-base")
def transcribe(audio):
"""Convert speech to text using Hugging Face ASR model."""
result = asr_pipeline(audio)
return result["text"]
# Gradio Interface
demo = gr.Interface(
fn=transcribe,
inputs=gr.Audio(type="filepath"), # Remove 'source' argument
outputs=gr.Textbox(label="Transcription"),
title="Speech to Text with Hugging Face ASR",
description="Click the button and speak. Your voice will be transcribed using OpenAI Whisper.",
live=True # Enables real-time transcription
)
demo.launch()