Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import torch
|
|
| 8 |
from datetime import timedelta
|
| 9 |
from pyannote.audio import Pipeline
|
| 10 |
from huggingface_hub import hf_hub_download
|
|
|
|
| 11 |
|
| 12 |
# --- Configuration & Tokens ---
|
| 13 |
HARDCODED_HF_TOKEN = "PASTE_YOUR_HF_TOKEN_HERE"
|
|
@@ -128,19 +129,10 @@ if uploaded_file:
|
|
| 128 |
|
| 129 |
# 1. Diarization with Manual Config Loading
|
| 130 |
try:
|
| 131 |
-
# Fix for PyTorch 2.6+ security
|
| 132 |
try:
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
from pyannote.audio.pipelines.speaker_diarization import SpeakerDiarization
|
| 136 |
-
|
| 137 |
-
torch.serialization.add_safe_globals([
|
| 138 |
-
torch.torch_version.TorchVersion,
|
| 139 |
-
Specifications,
|
| 140 |
-
Model,
|
| 141 |
-
SpeakerDiarization
|
| 142 |
-
])
|
| 143 |
-
except (AttributeError, ImportError):
|
| 144 |
pass
|
| 145 |
|
| 146 |
# Download config.yaml manually to bypass Pipeline.from_pretrained argument issues
|
|
@@ -150,8 +142,8 @@ if uploaded_file:
|
|
| 150 |
token=ACTIVE_HF_TOKEN
|
| 151 |
)
|
| 152 |
|
| 153 |
-
# Load pipeline from the local config file
|
| 154 |
-
pipeline = Pipeline.from_pretrained(config_path
|
| 155 |
|
| 156 |
if torch.cuda.is_available():
|
| 157 |
pipeline.to(torch.device("cuda"))
|
|
|
|
| 8 |
from datetime import timedelta
|
| 9 |
from pyannote.audio import Pipeline
|
| 10 |
from huggingface_hub import hf_hub_download
|
| 11 |
+
from pyannote.audio.core.task import Specifications # Import required for Safe Globals
|
| 12 |
|
| 13 |
# --- Configuration & Tokens ---
|
| 14 |
HARDCODED_HF_TOKEN = "PASTE_YOUR_HF_TOKEN_HERE"
|
|
|
|
| 129 |
|
| 130 |
# 1. Diarization with Manual Config Loading
|
| 131 |
try:
|
| 132 |
+
# Fix for PyTorch 2.6+ security
|
| 133 |
try:
|
| 134 |
+
torch.serialization.add_safe_globals([torch.torch_version.TorchVersion, Specifications])
|
| 135 |
+
except AttributeError:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
pass
|
| 137 |
|
| 138 |
# Download config.yaml manually to bypass Pipeline.from_pretrained argument issues
|
|
|
|
| 142 |
token=ACTIVE_HF_TOKEN
|
| 143 |
)
|
| 144 |
|
| 145 |
+
# Load pipeline from the local config file
|
| 146 |
+
pipeline = Pipeline.from_pretrained(config_path)
|
| 147 |
|
| 148 |
if torch.cuda.is_available():
|
| 149 |
pipeline.to(torch.device("cuda"))
|