whisper.asr / app.py
LimaRaed's picture
Create app.py
bb7408d verified
raw
history blame
692 Bytes
import gradio as gr
import torch
from transformers import pipeline
# Load Whisper model from Hugging Face
asr = pipeline("automatic-speech-recognition", model="openai/whisper-small", device=0 if torch.cuda.is_available() else -1)
# Function to transcribe audio
def transcribe(audio):
print("Received audio input.")
text = asr(audio)["text"]
return text
# Create Gradio Interface
demo = gr.Interface(
fn=transcribe,
inputs=gr.Audio(source="microphone", type="filepath"),
outputs="text",
title="🎙️ Whisper Voice Recognition",
description="Speak into your mic and get real-time transcription using OpenAI's Whisper ASR."
)
# Launch the app
demo.launch()