Skip to content

Commit

Permalink
Fix: Issue tyiannak#396, when chroma features can not be computed
Browse files Browse the repository at this point in the history
  • Loading branch information
Caparrini committed Mar 31, 2024
1 parent ae00ebd commit 02a5fc1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pyAudioAnalysis/ShortTermFeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,10 @@ def chroma_features(signal, sampling_rate, num_fft):
else:
I = np.nonzero(num_chroma > num_chroma.shape[0])[0][0]
C = np.zeros((num_chroma.shape[0],))
C[num_chroma[0:I - 1]] = spec
C /= num_freqs_per_chroma
if I > 1:
# If I <= 1 there are no chroma features that can be extracted
C[num_chroma[0:I - 1]] = spec[num_chroma[0:I - 1]]
C /= num_freqs_per_chroma
final_matrix = np.zeros((12, 1))
newD = int(np.ceil(C.shape[0] / 12.0) * 12)
C2 = np.zeros((newD,))
Expand Down

0 comments on commit 02a5fc1

Please sign in to comment.