diff --git a/server/server.py b/server/server.py index cb31fe8..bce6385 100644 --- a/server/server.py +++ b/server/server.py @@ -22,7 +22,7 @@ import sys if sys.version_info.major <= 2: from cStringIO import StringIO else: - from io import StringIO + from io import BytesIO import time import json @@ -34,7 +34,10 @@ app = Flask(__name__, static_url_path='', static_folder=os.path.abspath('../stat 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',