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