palli23 commited on
Commit
1170a88
·
1 Parent(s): a92236a

diarization1Mæló

Browse files
Files changed (2) hide show
  1. app.py +26 -14
  2. requirements.txt +1 -3
app.py CHANGED
@@ -1,27 +1,39 @@
1
- # app.py – 100 % virkar án pyannote/ECAPA bara þitt Whisper-small
2
  import os
3
  import gradio as gr
 
4
  from transformers import pipeline
5
 
6
- pipe = pipeline(
7
- "automatic-speech-recognition",
8
- model="palli23/whisper-small-sam_spjall",
9
- device=-1, # CPU fyrst (ZeroGPU PRO keyrir á GPU)
10
- token=os.getenv("HF_TOKEN")
11
- )
12
 
 
 
13
  def transcribe(audio):
14
  if not audio:
15
  return "Hladdu upp hljóðskrá"
16
- return pipe(audio)["text"]
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- with gr.Blocks() as demo:
19
- gr.Markdown("# Íslenskt ASR – Virkar 100 %")
20
- gr.Markdown("**Whisper-small · ~45 % WER · Einfalt og stöðugt**")
 
21
 
22
- audio = gr.Audio(type="filepath")
23
- btn = gr.Button("Transcribe")
24
- out = gr.Textbox(lines=20)
25
 
26
  btn.click(transcribe, audio, out)
27
 
 
1
+ # app.py – Whisper-small on ZeroGPU (PRO)0.2 RTF
2
  import os
3
  import gradio as gr
4
+ import spaces # Required for @spaces.GPU
5
  from transformers import pipeline
6
 
7
+ MODEL_NAME = "palli23/whisper-small-sam_spjall"
 
 
 
 
 
8
 
9
+ # Force ZeroGPU allocation for transcribe (A100/T4)
10
+ @spaces.GPU
11
  def transcribe(audio):
12
  if not audio:
13
  return "Hladdu upp hljóðskrá"
14
+
15
+ # Load pipeline on GPU (cached after first run)
16
+ pipe = pipeline(
17
+ "automatic-speech-recognition",
18
+ model=MODEL_NAME,
19
+ device=0, # GPU
20
+ token=os.getenv("HF_TOKEN")
21
+ )
22
+
23
+ try:
24
+ result = pipe(audio)
25
+ return result["text"]
26
+ except Exception as e:
27
+ return f"Villa: {str(e)}"
28
 
29
+ # Simple interface
30
+ with gr.Blocks(title="Íslenskt ASR – ZeroGPU GPU") as demo:
31
+ gr.Markdown("# Íslenskt ASR ZeroGPU (A100/T4)")
32
+ gr.Markdown("**Whisper-small · ~4 % WER · 0.2 RTF (15–25 sek fyrir 90 sek hljóð)**")
33
 
34
+ audio = gr.Audio(type="filepath", label="Hladdu upp .mp3 / .wav")
35
+ btn = gr.Button("Transcribe", variant="primary", size="lg")
36
+ out = gr.Textbox(lines=25, label="Útskrift")
37
 
38
  btn.click(transcribe, audio, out)
39
 
requirements.txt CHANGED
@@ -1,6 +1,4 @@
1
  gradio
2
  transformers
3
  torch
4
- spaces
5
- librosa
6
- soundfile
 
1
  gradio
2
  transformers
3
  torch
4
+ spaces # For @spaces.GPU