update3
Browse files- app.py +18 -13
- requirements.txt +2 -4
app.py
CHANGED
|
@@ -1,19 +1,24 @@
|
|
| 1 |
-
# app.py – VIRKAR
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import pipeline
|
| 4 |
-
import spaces # ← þetta er lykillinn
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
)
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
asr =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
def transcribe(audio):
|
| 19 |
if not audio:
|
|
@@ -25,7 +30,7 @@ def transcribe(audio):
|
|
| 25 |
return f"Villa: {str(e)}"
|
| 26 |
|
| 27 |
with gr.Blocks() as demo:
|
| 28 |
-
gr.Markdown("# Íslenskt ASR –
|
| 29 |
gr.Markdown("**Whisper-small · ~4–5 % WER · Keyrir á GPU**")
|
| 30 |
|
| 31 |
audio = gr.Audio(type="filepath", label="Hladdu upp .mp3 / .wav")
|
|
|
|
| 1 |
+
# app.py – VIRKAR Á A100 ÁN @spaces.GPU (2025 leiðin)
|
| 2 |
+
import os
|
| 3 |
import gradio as gr
|
| 4 |
from transformers import pipeline
|
|
|
|
| 5 |
|
| 6 |
+
# Þvingar GPU með torch (virkar alltaf á A100 Spaces)
|
| 7 |
+
import torch
|
| 8 |
+
if torch.cuda.is_available():
|
| 9 |
+
device = 0
|
| 10 |
+
print(f"GPU virk: {torch.cuda.get_device_name(0)}")
|
| 11 |
+
else:
|
| 12 |
+
device = -1
|
| 13 |
+
print("CPU – eitthvað er rangt við Space stillingar")
|
| 14 |
|
| 15 |
+
# Þitt private model
|
| 16 |
+
asr = pipeline(
|
| 17 |
+
"automatic-speech-recognition",
|
| 18 |
+
model="palli23/whisper-small-sam_spjall",
|
| 19 |
+
device=device,
|
| 20 |
+
token=os.getenv("HF_TOKEN")
|
| 21 |
+
)
|
| 22 |
|
| 23 |
def transcribe(audio):
|
| 24 |
if not audio:
|
|
|
|
| 30 |
return f"Villa: {str(e)}"
|
| 31 |
|
| 32 |
with gr.Blocks() as demo:
|
| 33 |
+
gr.Markdown("# Íslenskt ASR – VIRKAR Á A100")
|
| 34 |
gr.Markdown("**Whisper-small · ~4–5 % WER · Keyrir á GPU**")
|
| 35 |
|
| 36 |
audio = gr.Audio(type="filepath", label="Hladdu upp .mp3 / .wav")
|
requirements.txt
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
torch
|
| 2 |
-
transformers
|
| 3 |
gradio
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
| 1 |
gradio
|
| 2 |
+
transformers
|
| 3 |
+
torch
|