audio_to_midi_melodia icon indicating copy to clipboard operation
audio_to_midi_melodia copied to clipboard

Add support for Python 3

Open justinsalamon opened this issue 6 years ago • 9 comments

justinsalamon avatar Oct 30 '18 19:10 justinsalamon

I have the same question. We also need python3 support !

ucasiggcas avatar Feb 02 '19 06:02 ucasiggcas

What is broken with Python 3? I've just used it.

DavidParkin avatar Feb 15 '19 15:02 DavidParkin

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'

hpx7 avatar May 07 '19 01:05 hpx7

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!

justinsalamon avatar May 07 '19 19:05 justinsalamon

I fixed it as follow. change
notes.append((onset_sec, duration_sec, p_prev)) to notes.append((onset_sec, duration_sec, int(p_prev)))

moziguang avatar Mar 14 '20 07:03 moziguang

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.

Zipdox avatar May 25 '21 17:05 Zipdox

I changed the initialisation of p_prev (about line 107) to p_prev = 0

DavidParkin avatar May 26 '21 10:05 DavidParkin

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.

FoxesAreCute avatar Mar 05 '22 04:03 FoxesAreCute