| import gradio as gr |
| from transformers import pipeline |
|
|
| |
| MODEL_ID = "Akashpb13/xlsr_kurmanji_kurdish" |
|
|
| |
| |
| try: |
| transcriber = pipeline( |
| "automatic-speech-recognition", |
| model=MODEL_ID, |
| |
| ) |
| except Exception as e: |
| |
| gr.Warning(f"Failed to load model: {e}") |
| transcriber = None |
|
|
|
|
| |
| def transcribe_audio(audio_file_path): |
| if audio_file_path is None: |
| return "Please provide an audio input." |
|
|
| if transcriber is None: |
| return "Error: Model failed to initialize." |
|
|
| |
| result = transcriber(audio_file_path) |
| return result["text"] |
|
|
| |
| demo = gr.Interface( |
| fn=transcribe_audio, |
| inputs=gr.Audio( |
| sources=["microphone", "upload"], |
| type="filepath", |
| label="Kurmanji Audio Input" |
| ), |
| outputs=gr.Textbox(label="Kurmanji Transcription Result"), |
| title="Kurmanji ASR Demo", |
| description="Automatic Speech Recognition for Kurmanji using a fine-tuned Hugging Face Transformer model." |
| ) |
|
|
| |
| demo.launch() |