|
|
|
|
|
import os |
|
|
import gradio as gr |
|
|
from transformers import pipeline |
|
|
|
|
|
|
|
|
MODEL_NAME = "palli23/whisper-small-sam_spjall" |
|
|
|
|
|
|
|
|
pipe = pipeline( |
|
|
"automatic-speech-recognition", |
|
|
model=MODEL_NAME, |
|
|
device=0, |
|
|
token=os.getenv("HF_TOKEN") |
|
|
) |
|
|
|
|
|
def transcribe(audio): |
|
|
if not audio: |
|
|
return "Hladdu upp hljóð" |
|
|
result = pipe(audio) |
|
|
return result["text"] |
|
|
|
|
|
with gr.Blocks(theme=gr.themes.Soft()) as demo: |
|
|
gr.Markdown("# Íslenskt ASR – Beta") |
|
|
gr.Markdown("Whisper-small · ~4–5 % WER") |
|
|
|
|
|
audio = gr.Audio(type="filepath") |
|
|
btn = gr.Button("Transcribe") |
|
|
out = gr.Textbox(lines=20) |
|
|
|
|
|
btn.click(transcribe, audio, out) |
|
|
|
|
|
demo.launch(auth=("beta", "beta2025")) |