chord-detection icon indicating copy to clipboard operation
chord-detection copied to clipboard

KeyError: 'A♯'

Open youssefavx opened this issue 4 years ago • 4 comments

Thanks for making this! Really cool. I want to try it out, I ran this command on a 30 second file:

python3 multipitch.py erubescente.wav

And am getting this error:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/librosa/core/spectrum.py:224: UserWarning: n_fft=2048 is too small for input signal of length=511
  n_fft, y.shape[-1]
1 - ESACF (Tolonen, Karjalainen)
Traceback (most recent call last):
  File "multipitch.py", line 61, in <module>
    chromagram = compute_obj.compute_pitches(args.displayplots)
  File "/Volumes/Transcend/chord extraction/chord-detection/chord_detection/tolonen_karjalainen/esacf.py", line 68, in compute_pitches
    chromagram[note] += x_esacf[peak_indices[i]]
  File "/Volumes/Transcend/chord extraction/chord-detection/chord_detection/chromagram.py", line 21, in __getitem__
    return self.c[i]
KeyError: 'A♯'

Any ideas?

youssefavx avatar May 17 '21 20:05 youssefavx

Sorry, I missed the notification for this issue. Let me look into it.

sevagh avatar Oct 15 '21 12:10 sevagh

@youssefavx is there any way you can share the 30s audio clip so I can test it?

sevagh avatar Oct 15 '21 12:10 sevagh

If I had to guess, I'm not sure what symbol "♯" is, but I use "#", the regular hash mark: https://github.com/sevagh/chord-detection/blob/master/chord_detection/chromagram.py#L8

sevagh avatar Oct 15 '21 16:10 sevagh

I don't know which part of your code or operating system is replacing the regular # with a stylish ♯ but the second one is not one of the keys of the dict, so a KeyError is expected:

_note_names = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]

sevagh avatar Oct 15 '21 16:10 sevagh

Actually, this is an error on my part. It's related to a new librosa version. I'm patching it as we speak (commit to follow).

sevagh avatar Jul 14 '23 00:07 sevagh