Spaces:
Sleeping
Sleeping
| import time | |
| import gradio as gr | |
| from transformers import pipeline | |
| # Initialize the transcription pipeline using a Hugging Face model | |
| pipe = pipeline(model="Ussen/whisper-medium-swc-drc-kat-1") | |
| def transcribe_with_timing(audio): | |
| # Start timing | |
| start_time = time.time() | |
| # Perform transcription | |
| text = pipe(audio)["text"] | |
| # Calculate elapsed time | |
| elapsed_time = time.time() - start_time | |
| return text, f"Transcription time: {elapsed_time:.2f} seconds" | |
| # Create Gradio interface | |
| demo = gr.Interface( | |
| fn=transcribe_with_timing, | |
| inputs=gr.Audio(type="filepath", label="Bonyeza kitufe cha kurekodi na uliza swali lako"), | |
| outputs=[ | |
| gr.Textbox(label="Jibu (kwa njia ya maandishi)"), | |
| gr.Textbox(label="Transcription Time") | |
| ], | |
| description="Rekodi sauti yako na upate maandishi (Swahili ASR)", | |
| live=True | |
| ) | |
| demo.queue(api_open=True) | |
| demo.launch() |