File size: 1,009 Bytes
e0abf46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
import gradio as gr
from transformers import pipeline

# Load the Whisper model
model_name = "AventIQ-AI/whisper_small_Automatic_speech_recognition"
asr_pipeline = pipeline("automatic-speech-recognition", model=model_name)

def transcribe_audio(audio):
    if audio is None:
        return "⚠️ Please upload or record an audio file."
    
    transcript = asr_pipeline(audio)["text"]
    return transcript if transcript else "⚠️ No speech detected."

# Create Gradio UI
with gr.Blocks() as demo:
    gr.Markdown("## 🎀 Whisper Small - Speech to Text")
    gr.Markdown("Upload an audio file or record your voice to get a transcript.")

    audio_input = gr.Audio(type="filepath", interactive=True, label="πŸŽ™οΈ Upload or Record Audio")
    transcribe_button = gr.Button("πŸ” Transcribe")
    output_text = gr.Textbox(label="πŸ“ Transcription Output")

    transcribe_button.click(transcribe_audio, inputs=audio_input, outputs=output_text)

# Launch the app
demo.launch()