Spaces:
Runtime error
Runtime error
| from __future__ import annotations | |
| import gradio as gr | |
| from core import health, transcribe_audio_tuple, transcribe_base64 | |
| with gr.Blocks(title="Sinhala Flow") as demo: | |
| gr.Markdown( | |
| """ | |
| # 🎙️ Sinhala Flow | |
| Free Sinhala speech-to-text running on a Hugging Face CPU Space. | |
| Record a short Sinhala voice clip below to test the same model used by the Windows app. | |
| Audio and transcripts are not intentionally stored by this application. | |
| """ | |
| ) | |
| with gr.Row(): | |
| audio_input = gr.Audio(sources=["microphone", "upload"], type="numpy", label="Sinhala speech") | |
| transcript_output = gr.Textbox(label="Sinhala transcript", lines=6) | |
| transcribe_button = gr.Button("Transcribe", variant="primary") | |
| transcribe_button.click( | |
| fn=transcribe_audio_tuple, | |
| inputs=audio_input, | |
| outputs=transcript_output, | |
| concurrency_limit=1, | |
| ) | |
| # Hidden components expose compact JSON APIs for the Windows client. Base64 avoids | |
| # Gradio upload-file persistence and keeps each recording inside one queued request. | |
| api_audio = gr.Textbox(visible=False) | |
| api_language = gr.Textbox(value="si", visible=False) | |
| api_dictionary = gr.Textbox(value="{}", visible=False) | |
| api_result = gr.JSON(visible=False) | |
| api_button = gr.Button(visible=False) | |
| api_button.click( | |
| fn=transcribe_base64, | |
| inputs=[api_audio, api_language, api_dictionary], | |
| outputs=api_result, | |
| api_name="transcribe", | |
| concurrency_limit=1, | |
| ) | |
| health_result = gr.JSON(visible=False) | |
| health_button = gr.Button(visible=False) | |
| health_button.click(fn=health, inputs=[], outputs=health_result, api_name="health") | |
| demo.queue(max_size=8, default_concurrency_limit=1) | |
| if __name__ == "__main__": | |
| demo.launch() | |