Chord Recognition Using Librosa-problem with librosa.feature.chroma_cqt

412 views
Skip to first unread message

maneesha dendukuri

unread,
Mar 7, 2018, 5:24:28 PM3/7/18
to librosa

Hey everyone,
 So, I'm trying to implement chord recognition using a very simple model of template matching. But I tend to get errors in using the Librosa.feature.chroma_cqt() function.
I found this GitHub repo, which does the same, and i still get the same errors when i followed this repo.Link to Repo
Please help.

the error log is here:

File "PycharmProjects/pyML/chordgram.py", line 146, in <module>
    C = chromagram(file)
  File "\pyML\chromagram1.py", line 24, in chromagram
    chromagram = librosa.feature.chroma_cqt(y=y_harmonic, sr=sr, hop_length=hop_length)
  File "\Anaconda3\lib\site-packages\librosa\feature\spectral.py", line 936, in chroma_cqt
    real=False))
  File "Anaconda3\lib\site-packages\librosa\core\constantq.py", line 230, in cqt
    sparsity)
  File "\Anaconda3\lib\site-packages\librosa\core\constantq.py", line 490, in __cqt_filter_fft
    pad_fft=True)
  File "\Anaconda3\lib\site-packages\librosa\filters.py", line 601, in constant_q
    sig = sig * __float_window(window)(ilen)
  File "\Anaconda3\lib\site-packages\librosa\filters.py", line 447, in _wrap
    window = window_function(n, *args, **kwargs)
  File "\Anaconda3\lib\site-packages\scipy\signal\windows.py", line 807, in hann
    if _len_guards(M):
  File "\Anaconda3\lib\site-packages\scipy\signal\windows.py", line 19, in _len_guards
    raise ValueError('Window length M must be a non-negative integer')
ValueError: Window length M must be a non-negative integer

Brian McFee

unread,
Mar 8, 2018, 9:52:13 AM3/8/18
to librosa
What versions of librosa, numpy, and scipy do you have?

Decoding the error: it looks like the problem is that the CQT basis is trying to build a filter with a fractional length (in terms of samples).  This used to work in older versions of scipy, but in late 2016 they added the length guards.

We fixed this a while back in librosa, see this issue: https://github.com/librosa/librosa/issues/449  and the fix: https://github.com/librosa/librosa/pull/452 (merged 2016-12-01), so if you're on at least librosa 0.5 it shouldn't be a problem.

maneesha dendukuri

unread,
Mar 9, 2018, 5:11:11 PM3/9/18
to librosa
Thank you so much.It worked.Updating librosa to 0.6 totally fixed it.(I was on 0.4 before).
Reply all
Reply to author
Forward
0 new messages