Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3 #8

Open
justinsalamon opened this issue Oct 30, 2018 · 8 comments
Open

Add support for Python 3 #8

justinsalamon opened this issue Oct 30, 2018 · 8 comments

Comments

@justinsalamon
Copy link
Owner

No description provided.

@ucasiggcas
Copy link

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

@DavidParkin
Copy link

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

@hpx7
Copy link

hpx7 commented May 7, 2019

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'

@justinsalamon
Copy link
Owner Author

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!

@moziguang
Copy link

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

@DavidParkin
Copy link

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

@FoxesAreCute
Copy link

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.

@Wattbag
Copy link

Wattbag commented Jun 3, 2023

Great code Justin 👍 & Great fix guys !
Set p_prev = 0 at line 107
Replace p_prev by int(p_prev) at lines 121 & 133 and it just works fine in Python 3 !! Awesome result !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants
@DavidParkin @justinsalamon @hpx7 @moziguang @FoxesAreCute @ucasiggcas @Wattbag and others