Python3 compatibility
This commit is contained in:
parent
c17aa14601
commit
363b9b3a46
@ -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)
|
||||
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',
|
||||
|
Loading…
Reference in New Issue
Block a user