NickVerri commited on
Commit
146617f
·
verified ·
1 Parent(s): 1e58243

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -7
app.py CHANGED
@@ -131,20 +131,33 @@ if uploaded_file:
131
 
132
  # 1. Diarization
133
  try:
134
- # Fixed for recent pyannote.audio: separate model and revision
135
  model_id = "pyannote/speaker-diarization"
 
 
 
136
  try:
137
  pipeline = Pipeline.from_pretrained(
138
  model_id,
139
  revision="2.1",
140
  token=ACTIVE_HF_TOKEN
141
  )
142
- except TypeError:
143
- # Fallback if 'revision' isn't supported in old versions
144
- pipeline = Pipeline.from_pretrained(
145
- f"{model_id}@2.1",
146
- use_auth_token=ACTIVE_HF_TOKEN
147
- )
 
 
 
 
 
 
 
 
 
 
148
 
149
  if torch.cuda.is_available():
150
  pipeline.to(torch.device("cuda"))
 
131
 
132
  # 1. Diarization
133
  try:
134
+ # Ultra-robust initialization for pyannote.audio to prevent Revision errors
135
  model_id = "pyannote/speaker-diarization"
136
+ pipeline = None
137
+
138
+ # Attempt 1: Modern syntax (revision keyword)
139
  try:
140
  pipeline = Pipeline.from_pretrained(
141
  model_id,
142
  revision="2.1",
143
  token=ACTIVE_HF_TOKEN
144
  )
145
+ except Exception:
146
+ # Attempt 2: Modern syntax with string token
147
+ try:
148
+ pipeline = Pipeline.from_pretrained(
149
+ f"{model_id}@2.1",
150
+ use_auth_token=ACTIVE_HF_TOKEN
151
+ )
152
+ except Exception:
153
+ # Attempt 3: Basic string (no revision specified in name)
154
+ pipeline = Pipeline.from_pretrained(
155
+ model_id,
156
+ use_auth_token=ACTIVE_HF_TOKEN
157
+ )
158
+
159
+ if pipeline is None:
160
+ raise ValueError("Could not initialize the pyannote pipeline.")
161
 
162
  if torch.cuda.is_available():
163
  pipeline.to(torch.device("cuda"))