Thanh-Lam commited on
Commit
d2997d8
·
1 Parent(s): 56dc9d8

Fix Pipeline.from_pretrained() to support both token and use_auth_token parameters

Browse files
Files changed (1) hide show
  1. src/models.py +8 -1
src/models.py CHANGED
@@ -33,7 +33,14 @@ class DiarizationEngine:
33
  ) -> None:
34
  self.device = self._resolve_device(device)
35
  auth_token = read_hf_token(token, key_path)
36
- pipeline = Pipeline.from_pretrained(model_id, token=auth_token)
 
 
 
 
 
 
 
37
  params = pipeline.parameters()
38
  # Giảm phân mảnh: chỉ cập nhật các khóa thực sự tồn tại để tránh lỗi.
39
  seg_cfg = params.get("segmentation")
 
33
  ) -> None:
34
  self.device = self._resolve_device(device)
35
  auth_token = read_hf_token(token, key_path)
36
+
37
+ # Try newer 'token' parameter first, fallback to legacy 'use_auth_token'
38
+ try:
39
+ pipeline = Pipeline.from_pretrained(model_id, token=auth_token)
40
+ except TypeError:
41
+ # Older pyannote.audio versions use 'use_auth_token'
42
+ pipeline = Pipeline.from_pretrained(model_id, use_auth_token=auth_token)
43
+
44
  params = pipeline.parameters()
45
  # Giảm phân mảnh: chỉ cập nhật các khóa thực sự tồn tại để tránh lỗi.
46
  seg_cfg = params.get("segmentation")