Spaces:
Sleeping
Sleeping
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() | |