File size: 692 Bytes
bb7408d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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()