audio_to_midi_melodia
audio_to_midi_melodia copied to clipboard
Add support for Python 3
I have the same question. We also need python3 support !
What is broken with Python 3? I've just used it.
It doesn't seem to work with Python3:
Loading audio...
Extracting melody f0 with MELODIA...
Converting Hz to MIDI notes...
Traceback (most recent call last):
File "audio_to_midi_melodia.py", line 225, in <module>
savejams=args.jams)
File "audio_to_midi_melodia.py", line 191, in audio_to_midi_melodia
notes = midi_to_notes(midi_pitch, fs, hop, smooth, minduration)
File "audio_to_midi_melodia.py", line 115, in midi_to_notes
if p_prev > 0:
TypeError: '>' not supported between instances of 'NoneType' and 'int'
This specific error is described in #5. Fixing this issue seems straight forward, full python 3 support might require a few more changes. I'll have time to look into python 3 support in about 1 month. In the meanwhile, the easiest solution is to create a python 2.7 environment (e.g. using miniconda) and run the script from within this environment. Thanks in advance for your patience!
I fixed it as follow.
change
notes.append((onset_sec, duration_sec, p_prev))
to
notes.append((onset_sec, duration_sec, int(p_prev)))
I fixed it as follow. change notes.append((onset_sec, duration_sec, p_prev)) to notes.append((onset_sec, duration_sec, int(p_prev)))
That doesn't fix anything.
I changed the initialisation of p_prev (about line 107) to
p_prev = 0
I just want to add, there are two instances of p_prev you need to change. Line 126, and 107. Otherwise you get the error specified here
The codes sound, no pun intended and it's honestly amazing how it works with such a newer version of python so easily. I wouldn't abandon this project, it has a LOT of potential for DJs, Parody makers, and samplers like me alike.