mineeuk commited on
Commit
67d992f
·
1 Parent(s): a7ad714

fix: remove torchcodec, add ffmpeg system pkg, monkey-patch torchaudio to use soundfile backend

Browse files
Files changed (3) hide show
  1. app.py +23 -0
  2. packages.txt +2 -0
  3. requirements.txt +0 -1
app.py CHANGED
@@ -3,6 +3,29 @@ import gradio as gr
3
  import torch
4
  import librosa
5
  import numpy as np
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  from inference import inference
7
  from huggingface_hub import hf_hub_download
8
  from pathlib import Path
 
3
  import torch
4
  import librosa
5
  import numpy as np
6
+
7
+ # Patch torchaudio to use soundfile backend globally.
8
+ # PyTorch 2.9+ defaults to torchcodec which requires FFmpeg shared libs
9
+ # that are incompatible with the HF Space environment.
10
+ import torchaudio
11
+
12
+ _orig_torchaudio_load = torchaudio.load
13
+ _orig_torchaudio_info = torchaudio.info
14
+
15
+
16
+ def _patched_load(*args, **kwargs):
17
+ kwargs.setdefault("backend", "soundfile")
18
+ return _orig_torchaudio_load(*args, **kwargs)
19
+
20
+
21
+ def _patched_info(*args, **kwargs):
22
+ kwargs.setdefault("backend", "soundfile")
23
+ return _orig_torchaudio_info(*args, **kwargs)
24
+
25
+
26
+ torchaudio.load = _patched_load
27
+ torchaudio.info = _patched_info
28
+
29
  from inference import inference
30
  from huggingface_hub import hf_hub_download
31
  from pathlib import Path
packages.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ffmpeg
2
+ libsndfile1-dev
requirements.txt CHANGED
@@ -2,7 +2,6 @@ https://github.com/CPJKU/beat_this/archive/main.zip
2
  gradio>=4.0.0
3
  torch>=2.0.0
4
  torchaudio>=2.0.0
5
- torchcodec
6
  pytorch-lightning>=2.0.0
7
  transformers>=4.46.0
8
  huggingface_hub>=0.25.0,<1.0.0
 
2
  gradio>=4.0.0
3
  torch>=2.0.0
4
  torchaudio>=2.0.0
 
5
  pytorch-lightning>=2.0.0
6
  transformers>=4.46.0
7
  huggingface_hub>=0.25.0,<1.0.0