sevahu97 commited on
Commit
b607996
·
verified ·
1 Parent(s): 076bcbf

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. ear/semantic.py +8 -5
  2. requirements.txt +4 -2
ear/semantic.py CHANGED
@@ -129,12 +129,15 @@ class _Semantic:
129
  best_e, best_s = e, s
130
  mono48 = mono48[best_s : best_s + want]
131
 
 
132
  with self._lock, torch.no_grad():
133
- inputs = self._processor(
134
- audios=mono48.astype(np.float32),
135
- sampling_rate=CLAP_SR,
136
- return_tensors="pt",
137
- )
 
 
138
  audio_emb = self._model.get_audio_features(**inputs)
139
  audio_emb = audio_emb / audio_emb.norm(dim=-1, keepdim=True)
140
  sims = (audio_emb @ self._text_emb.T).squeeze(0).cpu().numpy()
 
129
  best_e, best_s = e, s
130
  mono48 = mono48[best_s : best_s + want]
131
 
132
+ clip = mono48.astype(np.float32)
133
  with self._lock, torch.no_grad():
134
+ # transformers 4.x takes `audios`, 5.x renamed it to `audio`.
135
+ try:
136
+ inputs = self._processor(audio=clip, sampling_rate=CLAP_SR,
137
+ return_tensors="pt")
138
+ except TypeError:
139
+ inputs = self._processor(audios=clip, sampling_rate=CLAP_SR,
140
+ return_tensors="pt")
141
  audio_emb = self._model.get_audio_features(**inputs)
142
  audio_emb = audio_emb / audio_emb.norm(dim=-1, keepdim=True)
143
  sims = (audio_emb @ self._text_emb.T).squeeze(0).cpu().numpy()
requirements.txt CHANGED
@@ -5,5 +5,7 @@ numpy
5
  scipy
6
  soundfile
7
  torch==2.6.0+cpu
8
- # ClapProcessor's audio kwarg was renamed in the 5.x line; pin to the 4.x API.
9
- transformers>=4.44,<5
 
 
 
5
  scipy
6
  soundfile
7
  torch==2.6.0+cpu
8
+ # Unpinned on purpose: pinning <5 forces huggingface-hub<1.0, which collides
9
+ # with the version the Spaces runtime preinstalls. semantic.py handles the
10
+ # 4.x/5.x processor signature difference at the call site instead.
11
+ transformers