S-Vetrivel commited on
Commit
e53bdb6
·
1 Parent(s): d399729

Fix: Apply compatibility patches before speechbrain import

Browse files
Files changed (1) hide show
  1. app/main.py +17 -0
app/main.py CHANGED
@@ -4,6 +4,23 @@ import sys
4
  # Add project root to sys.path to allow importing 'src'
5
  sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  import time
8
  import base64
9
  import traceback
 
4
  # Add project root to sys.path to allow importing 'src'
5
  sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
6
 
7
+ # CRITICAL: Apply compatibility patches BEFORE any speechbrain imports
8
+ import torchaudio
9
+ if not hasattr(torchaudio, "list_audio_backends"):
10
+ def _list_audio_backends():
11
+ return ["soundfile"]
12
+ torchaudio.list_audio_backends = _list_audio_backends
13
+
14
+ import huggingface_hub
15
+ _original_hf_hub_download = huggingface_hub.hf_hub_download
16
+ def _patched_hf_hub_download(*args, **kwargs):
17
+ if "use_auth_token" in kwargs:
18
+ token_val = kwargs.pop("use_auth_token")
19
+ if "token" not in kwargs:
20
+ kwargs["token"] = token_val
21
+ return _original_hf_hub_download(*args, **kwargs)
22
+ huggingface_hub.hf_hub_download = _patched_hf_hub_download
23
+
24
  import time
25
  import base64
26
  import traceback