Luigi commited on
Commit
d0509e1
·
1 Parent(s): c5bcdb3

fallback to spk diaraization 2.1 if error

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -105,10 +105,18 @@ def get_diarization_pipe():
105
  if dar_pipe is None:
106
  # Pull token from environment (HF_TOKEN or HUGGINGFACE_TOKEN)
107
  token = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACE_TOKEN")
108
- dar_pipe = DiarizationPipeline.from_pretrained(
109
- "pyannote/speaker-diarization-3.1",
110
- use_auth_token=token or True
111
- )
 
 
 
 
 
 
 
 
112
  return dar_pipe
113
 
114
  # —————— Transcription Functions ——————
 
105
  if dar_pipe is None:
106
  # Pull token from environment (HF_TOKEN or HUGGINGFACE_TOKEN)
107
  token = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACE_TOKEN")
108
+ # Attempt to load the latest 3.1 pipeline, fallback to 2.1 if gated segmentation-3.0 isn't accepted
109
+ try:
110
+ dar_pipe = DiarizationPipeline.from_pretrained(
111
+ "pyannote/speaker-diarization-3.1",
112
+ use_auth_token=token or True
113
+ )
114
+ except Exception as e:
115
+ print(f"Failed to load pyannote/speaker-diarization-3.1: {e} Falling back to pyannote/[email protected].")
116
+ dar_pipe = DiarizationPipeline.from_pretrained(
117
+ "pyannote/[email protected]",
118
+ use_auth_token=token or True
119
+ )
120
  return dar_pipe
121
 
122
  # —————— Transcription Functions ——————