diarization1Mæló
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# app.py –
|
| 2 |
import os
|
| 3 |
import gradio as gr
|
| 4 |
import spaces
|
|
@@ -6,7 +6,7 @@ from transformers import pipeline
|
|
| 6 |
from pyannote.audio import Pipeline
|
| 7 |
import torch
|
| 8 |
import tempfile
|
| 9 |
-
from torch.serialization import safe_globals
|
| 10 |
|
| 11 |
MODEL_NAME = "palli23/whisper-small-sam_spjall"
|
| 12 |
|
|
@@ -15,16 +15,17 @@ def transcribe_with_diarization(audio_path):
|
|
| 15 |
if not audio_path:
|
| 16 |
return "Hladdu upp hljóðskrá"
|
| 17 |
|
| 18 |
-
# FIX:
|
| 19 |
with safe_globals([
|
| 20 |
torch.torch_version.TorchVersion,
|
| 21 |
-
'pyannote.audio.core.task.Specifications'
|
| 22 |
]):
|
| 23 |
diarization = Pipeline.from_pretrained(
|
| 24 |
"pyannote/speaker-diarization-3.1",
|
| 25 |
token=os.getenv("HF_TOKEN")
|
| 26 |
).to("cuda")
|
| 27 |
|
|
|
|
| 28 |
dia = diarization(audio_path)
|
| 29 |
|
| 30 |
# Whisper-small
|
|
@@ -47,13 +48,16 @@ def transcribe_with_diarization(audio_path):
|
|
| 47 |
|
| 48 |
return "\n".join(result) or "Ekkert heyrt"
|
| 49 |
|
| 50 |
-
#
|
| 51 |
with gr.Blocks() as demo:
|
| 52 |
gr.Markdown("# Íslenskt ASR + Mælendagreining")
|
| 53 |
-
gr.Markdown("**Whisper-small + pyannote 3.1 ·
|
|
|
|
| 54 |
|
| 55 |
-
audio = gr.Audio(type="filepath")
|
| 56 |
-
btn = gr.Button("Transcribe með mælendum", variant="primary")
|
| 57 |
-
out = gr.Textbox(lines=35)
|
| 58 |
|
| 59 |
-
btn.click(transcribe_with_diarization
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py – Whisper-small + Mælendagreining (pyannote 3.1) – VIRKAR Á ZeroGPU
|
| 2 |
import os
|
| 3 |
import gradio as gr
|
| 4 |
import spaces
|
|
|
|
| 6 |
from pyannote.audio import Pipeline
|
| 7 |
import torch
|
| 8 |
import tempfile
|
| 9 |
+
from torch.serialization import safe_globals
|
| 10 |
|
| 11 |
MODEL_NAME = "palli23/whisper-small-sam_spjall"
|
| 12 |
|
|
|
|
| 15 |
if not audio_path:
|
| 16 |
return "Hladdu upp hljóðskrá"
|
| 17 |
|
| 18 |
+
# FIX: PyTorch 2.6+ unpickling villu (ZeroGPU krefst þess)
|
| 19 |
with safe_globals([
|
| 20 |
torch.torch_version.TorchVersion,
|
| 21 |
+
'pyannote.audio.core.task.Specifications'
|
| 22 |
]):
|
| 23 |
diarization = Pipeline.from_pretrained(
|
| 24 |
"pyannote/speaker-diarization-3.1",
|
| 25 |
token=os.getenv("HF_TOKEN")
|
| 26 |
).to("cuda")
|
| 27 |
|
| 28 |
+
# Keyra mælendagreiningu
|
| 29 |
dia = diarization(audio_path)
|
| 30 |
|
| 31 |
# Whisper-small
|
|
|
|
| 48 |
|
| 49 |
return "\n".join(result) or "Ekkert heyrt"
|
| 50 |
|
| 51 |
+
# Gradio interface
|
| 52 |
with gr.Blocks() as demo:
|
| 53 |
gr.Markdown("# Íslenskt ASR + Mælendagreining")
|
| 54 |
+
gr.Markdown("**Whisper-small + pyannote 3.1 · Full podcast-transcript**")
|
| 55 |
+
gr.Markdown("Hladdu upp .mp3 / .wav (allt að 5 mín)")
|
| 56 |
|
| 57 |
+
audio = gr.Audio(type="filepath", label="Hljóðskrá")
|
| 58 |
+
btn = gr.Button("Transcribe með mælendum", variant="primary", size="lg")
|
| 59 |
+
out = gr.Textbox(lines=35, label="Útskrift með mælendum")
|
| 60 |
|
| 61 |
+
btn.click(transcribe_with_diarization, inputs=audio, outputs=out)
|
| 62 |
+
|
| 63 |
+
demo.launch(auth=("beta", "beta2025"))
|