| import gradio as gr |
| from transformers import pipeline |
| import torch |
| import time |
|
|
| print("=== Starting app ===") |
| print(f"CUDA available: {torch.cuda.is_available()}") |
|
|
| pipe = None |
|
|
| try: |
| print("Loading model...") |
| t0 = time.time() |
| pipe = pipeline( |
| "automatic-speech-recognition", |
| model="Za6na/my-sorani-stt", |
| device=-1, |
| torch_dtype=torch.float32, |
| ) |
| print(f"β
Model loaded in {time.time() - t0:.1f}s") |
| except Exception as e: |
| print(f"β Model failed to load: {e}") |
| pipe = None |
|
|
|
|
| def transcribe(audio): |
| if pipe is None: |
| return "β Model failed to load. Check Space logs." |
| if audio is None: |
| return "Please provide audio." |
| try: |
| result = pipe(audio) |
| return result["text"] |
| except Exception as e: |
| return f"β Transcription error: {e}" |
|
|
|
|
| demo = gr.Interface( |
| fn=transcribe, |
| inputs=gr.Audio(type="filepath"), |
| outputs=gr.Textbox(label="Kurdish Sorani Transcription"), |
| title="Sorani Kurdish STT ποΈ", |
| description="Upload or record audio to transcribe into Kurdish Sorani text.", |
| ) |
|
|
| demo.launch() |