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

Python3 compatibility #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions server/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tensorflow==0.12.1
magenta==0.1.8
tensorflow
magenta
Flask==0.12
gunicorn==19.6.0
ipython==5.1.0
ipython==5.1.0
7 changes: 5 additions & 2 deletions server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
if sys.version_info.major <= 2:
from cStringIO import StringIO
else:
from io import StringIO
from io import BytesIO
import time
import json

Expand All @@ -34,7 +34,10 @@
def predict():
now = time.time()
values = json.loads(request.data)
midi_data = pretty_midi.PrettyMIDI(StringIO(''.join(chr(v) for v in values)))
if sys.version_info.major <= 2:
midi_data = pretty_midi.PrettyMIDI(StringIO(''.join(chr(v) for v in values)))
else:
midi_data = pretty_midi.PrettyMIDI(BytesIO(b''.join([v.to_bytes(1,'big') for v in values])))
duration = float(request.args.get('duration'))
ret_midi = generate_midi(midi_data, duration)
return send_file(ret_midi, attachment_filename='return.mid',
Expand Down