diarization1Mæló
Browse files
app.py
CHANGED
|
@@ -1,17 +1,28 @@
|
|
| 1 |
# ============================================================
|
| 2 |
-
# app.py – Whisper-small + Pyannote
|
| 3 |
# ============================================================
|
| 4 |
|
| 5 |
import os
|
| 6 |
import gradio as gr
|
| 7 |
import spaces
|
| 8 |
import tempfile
|
|
|
|
|
|
|
| 9 |
from transformers import pipeline
|
| 10 |
from pyannote.audio import Pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
ASR_MODEL = "palli23/whisper-small-sam_spjall"
|
| 14 |
-
DIAR_MODEL = "pyannote/speaker-diarization
|
| 15 |
|
| 16 |
|
| 17 |
@spaces.GPU(duration=120)
|
|
@@ -22,10 +33,11 @@ def transcribe_with_diarization(audio_path):
|
|
| 22 |
|
| 23 |
# ----------------------------
|
| 24 |
# 1. Load diarization pipeline
|
|
|
|
| 25 |
# ----------------------------
|
| 26 |
diarization = Pipeline.from_pretrained(
|
| 27 |
DIAR_MODEL,
|
| 28 |
-
|
| 29 |
).to("cuda")
|
| 30 |
|
| 31 |
diar = diarization(audio_path)
|
|
@@ -63,9 +75,9 @@ def transcribe_with_diarization(audio_path):
|
|
| 63 |
# ------------------------------------------------------------
|
| 64 |
with gr.Blocks() as demo:
|
| 65 |
gr.Markdown("# 🎙️ Íslenskt ASR + mælendagreining")
|
| 66 |
-
gr.Markdown("Whisper-small + pyannote
|
| 67 |
|
| 68 |
-
audio = gr.Audio(type="filepath", label="Hlaða inn hljóði (.wav
|
| 69 |
out = gr.Textbox(lines=30, label="Útskrift með mælendum")
|
| 70 |
|
| 71 |
btn = gr.Button("Transcribe með mælendum", variant="primary")
|
|
|
|
| 1 |
# ============================================================
|
| 2 |
+
# app.py – Whisper-small + Pyannote 3.1 (ZeroGPU örugg)
|
| 3 |
# ============================================================
|
| 4 |
|
| 5 |
import os
|
| 6 |
import gradio as gr
|
| 7 |
import spaces
|
| 8 |
import tempfile
|
| 9 |
+
import torch
|
| 10 |
+
|
| 11 |
from transformers import pipeline
|
| 12 |
from pyannote.audio import Pipeline
|
| 13 |
+
from torch.serialization import add_safe_globals
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
# ================================================
|
| 17 |
+
# Workaround fyrir PyTorch 2.6 weights-only unpickling
|
| 18 |
+
# ================================================
|
| 19 |
+
add_safe_globals({
|
| 20 |
+
"Specifications": "pyannote.audio.core.task",
|
| 21 |
+
})
|
| 22 |
|
| 23 |
|
| 24 |
ASR_MODEL = "palli23/whisper-small-sam_spjall"
|
| 25 |
+
DIAR_MODEL = "pyannote/speaker-diarization-3.1"
|
| 26 |
|
| 27 |
|
| 28 |
@spaces.GPU(duration=120)
|
|
|
|
| 33 |
|
| 34 |
# ----------------------------
|
| 35 |
# 1. Load diarization pipeline
|
| 36 |
+
# (ENGINN token parameter!)
|
| 37 |
# ----------------------------
|
| 38 |
diarization = Pipeline.from_pretrained(
|
| 39 |
DIAR_MODEL,
|
| 40 |
+
cache_dir="/home/user/.cache"
|
| 41 |
).to("cuda")
|
| 42 |
|
| 43 |
diar = diarization(audio_path)
|
|
|
|
| 75 |
# ------------------------------------------------------------
|
| 76 |
with gr.Blocks() as demo:
|
| 77 |
gr.Markdown("# 🎙️ Íslenskt ASR + mælendagreining")
|
| 78 |
+
gr.Markdown("Whisper-small + pyannote 3.1 (ZeroGPU örugg útgáfa)")
|
| 79 |
|
| 80 |
+
audio = gr.Audio(type="filepath", label="Hlaða inn hljóði (.wav / .mp3)")
|
| 81 |
out = gr.Textbox(lines=30, label="Útskrift með mælendum")
|
| 82 |
|
| 83 |
btn = gr.Button("Transcribe með mælendum", variant="primary")
|