Spaces:
Runtime error
Runtime error
Rename app.py(bad) to app.py
Browse filesFiles changed (2)
- app.pyAdded+26
- app.py(bad)Deleted-46
1234567891011121314151617181920212223242526import gradio as grimport librosafrom asr import transcribe_auto, ASR_EXAMPLES, ASR_NOTE # Modify transcribe_auto to auto-detect language
# Speech-to-Text Interface without language selectionmms_transcribe = gr.Interface( fn=transcribe_auto, # Function that automatically detects language inputs=gr.Audio(), outputs="text", examples=ASR_EXAMPLES, title="Speech-to-Text", description="Automatically transcribes audio in either English or Swahili.", article=ASR_NOTE, allow_flagging="never",)
# Main Gradio Appwith gr.Blocks() as demo: gr.Markdown("<p align='center' style='font-size: 20px;'>MMS Speech-to-Text</p>") gr.HTML("<center>Automatically convert speech to text in English or Swahili.</center>")
mms_transcribe.render()
if __name__ == "__main__": demo.queue() demo.launch()12345678910111213141516171819202122232425262728293031323334353637383940414243444546import gradio as grimport librosafrom asr import transcribe, ASR_EXAMPLES, ASR_NOTEfrom lid import identify # Import Language Identification model
# Function to detect language and transcribe speechdef auto_transcribe(audio): # Detect language detected_lang = identify(audio) # Debug: Print detected language print(f"Detected Language: {detected_lang}")
# Ensure the detected language is Swahili or English if detected_lang.startswith("swh"): detected_lang = "swh" elif detected_lang.startswith("eng"): detected_lang = "eng" else: return f"Error: Detected language '{detected_lang}' is not supported."
# Transcribe using detected language return transcribe(audio, lang=detected_lang)
# Speech-to-Text Interface with Auto Language Detectionmms_transcribe = gr.Interface( fn=auto_transcribe, inputs=gr.Audio(), outputs="text", examples=ASR_EXAMPLES, title="Speech-to-Text (Auto Language Detection)", description="Automatically detects whether speech is in Swahili or English and transcribes it.", article=ASR_NOTE, allow_flagging="never",)
# Main Gradio Appwith gr.Blocks() as demo: gr.Markdown("<p align='center' style='font-size: 20px;'>MMS Speech-to-Text</p>") gr.HTML("<center>Automatically detects and transcribes Swahili or English speech.</center>")
mms_transcribe.render()
if __name__ == "__main__": demo.queue() demo.launch()app.pyAdded+26
app.py(bad)Deleted-46