niks1419 commited on
Commit
e075b97
·
verified ·
1 Parent(s): 52a2768

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -18,6 +18,7 @@ import soundfile as sf
18
  import librosa
19
  import noisereduce as nr
20
  import gradio as gr
 
21
 
22
  # Lazy imports (heavy models) will be done inside the worker function
23
  # to keep the app responsive on startup.
@@ -133,6 +134,18 @@ def pipeline_worker(video_file_path: str, keywords: List[str]):
133
  yield from emit(f"ERROR loading audio: {e}")
134
  return
135
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  # Lazy-load heavy models
137
  yield from emit("Loading diarization & embedding models (this can take a while)...")
138
  HF_TOKEN = os.environ.get("HF_TOKEN_1")
@@ -140,8 +153,8 @@ def pipeline_worker(video_file_path: str, keywords: List[str]):
140
  try:
141
  from pyannote.audio import Pipeline, Model
142
  # diarize_pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization@2022.07", use_auth_token=HF_TOKEN)
143
- diarize_pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization")
144
- embedding_model = Model.from_pretrained("pyannote/embedding")
145
 
146
  yield from emit("pyannote models loaded.")
147
  except Exception as e:
 
18
  import librosa
19
  import noisereduce as nr
20
  import gradio as gr
21
+ import huggingface_hub
22
 
23
  # Lazy imports (heavy models) will be done inside the worker function
24
  # to keep the app responsive on startup.
 
134
  yield from emit(f"ERROR loading audio: {e}")
135
  return
136
 
137
+
138
+ if "use_auth_token" in inspect.signature(huggingface_hub.hf_hub_download).parameters:
139
+ pass # old version, fine
140
+ else:
141
+ # patch for backward compatibility
142
+ def hf_hub_download_patch(*args, use_auth_token=None, **kwargs):
143
+ if use_auth_token is not None:
144
+ kwargs["token"] = use_auth_token
145
+ return huggingface_hub.hf_hub_download(*args, **kwargs)
146
+ huggingface_hub.hf_hub_download = hf_hub_download_patch
147
+
148
+
149
  # Lazy-load heavy models
150
  yield from emit("Loading diarization & embedding models (this can take a while)...")
151
  HF_TOKEN = os.environ.get("HF_TOKEN_1")
 
153
  try:
154
  from pyannote.audio import Pipeline, Model
155
  # diarize_pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization@2022.07", use_auth_token=HF_TOKEN)
156
+ diarize_pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization", use_auth_token =HF_TOKEN_E)
157
+ embedding_model = Model.from_pretrained("pyannote/embedding", use_auth_token = HF_TOKEN_E)
158
 
159
  yield from emit("pyannote models loaded.")
160
  except Exception as e: