kab-asr-tanti / app.py
AitBAD's picture
Update app.py
3a30a88 verified
raw
history blame
1.13 kB
# app.py
import gradio as gr
from backend import KabyleASR
# Initialize ASR (happens once at startup)
asr = KabyleASR()
def transcribe_audio(audio):
if audio is None:
return "Please upload or record an audio file."
return asr.transcribe(audio)
# Gradio Interface
with gr.Blocks() as demo:
gr.Markdown("""
# 🎀 Tanti: Kabyle ASR (Free Tier)
Upload a Kabyle audio file or **record live** using your microphone.
⚠️ *Transcription may take 30–60 seconds due to CPU-only processing.*
""")
with gr.Row():
audio_input = gr.Audio(
sources=["upload", "microphone"], # βœ… Fixed: Added microphone
type="filepath",
label="Record or Upload Audio"
)
with gr.Row():
transcribe_btn = gr.Button("Transcribe")
with gr.Row():
output_text = gr.Textbox(label="Transcription", lines=8)
# Connect button to function
transcribe_btn.click(fn=transcribe_audio, inputs=audio_input, outputs=output_text)
# Launch without SSR (required for Hugging Face)
if __name__ == "__main__":
demo.launch(ssr_mode=False)