README / app.py
Shwan108's picture
Update app.py
5ce0d73 verified
Raw
History Blame Contribute Delete
1.16 kB
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, # Force CPU β€” safer on free Spaces
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()