Spaces:
Sleeping
Sleeping
File size: 1,128 Bytes
aab61cd 93e6695 3a30a88 aab61cd 93e6695 aab61cd 3a30a88 aab61cd 93e6695 3a30a88 63b20f3 3a30a88 63b20f3 3a30a88 63b20f3 3a30a88 63b20f3 3697d7f 3a30a88 aab61cd | 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 28 29 30 31 32 33 34 35 36 37 38 39 | # 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) |