Kabatubare commited on
Commit
4a724b6
·
verified ·
1 Parent(s): a0d5e71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -13,7 +13,11 @@ def custom_feature_extraction(audio, sr=16000, n_mels=128, n_fft=2048, hop_lengt
13
  S_DB = librosa.power_to_db(S, ref=np.max)
14
  pitches, _ = librosa.piptrack(y=audio, sr=sr, n_fft=n_fft, hop_length=hop_length)
15
  spectral_centroids = librosa.feature.spectral_centroid(y=audio, sr=sr, n_fft=n_fft, hop_length=hop_length)
16
- features = np.concatenate([S_DB, pitches.max(axis=1, keepdims=True), spectral_centroids], axis=0)
 
 
 
 
17
  features_tensor = torch.tensor(features).float()
18
  if features_tensor.shape[1] > target_length:
19
  features_tensor = features_tensor[:, :target_length]
@@ -51,3 +55,4 @@ iface = gr.Interface(
51
  )
52
 
53
  iface.launch()
 
 
13
  S_DB = librosa.power_to_db(S, ref=np.max)
14
  pitches, _ = librosa.piptrack(y=audio, sr=sr, n_fft=n_fft, hop_length=hop_length)
15
  spectral_centroids = librosa.feature.spectral_centroid(y=audio, sr=sr, n_fft=n_fft, hop_length=hop_length)
16
+ # Correct the dimensionality issue
17
+ pitches_max = np.max(pitches, axis=0, keepdims=True)
18
+ spectral_centroids = spectral_centroids.reshape(1, -1)
19
+ # Ensure the concatenation axis has matching dimensions
20
+ features = np.concatenate([S_DB, pitches_max, spectral_centroids], axis=0)
21
  features_tensor = torch.tensor(features).float()
22
  if features_tensor.shape[1] > target_length:
23
  features_tensor = features_tensor[:, :target_length]
 
55
  )
56
 
57
  iface.launch()
58
+