From fddf475400fc92aa1c466d0d26e54cb3f4204391 Mon Sep 17 00:00:00 2001 From: wataru Date: Wed, 14 Sep 2022 05:48:34 +0900 Subject: [PATCH] update --- docs/assets/setting.json | 2 +- docs/recorderServer.py | 37 +++++++++++++++++----------- template/setting_recorder_colab.json | 25 +++++++++++++++++++ 3 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 template/setting_recorder_colab.json diff --git a/docs/assets/setting.json b/docs/assets/setting.json index 3fcf3834..4738061a 100644 --- a/docs/assets/setting.json +++ b/docs/assets/setting.json @@ -1,7 +1,7 @@ { "app_title": "voice-recorder", "storage_type":"local", - "use_mel_spectrogram":false, + "use_mel_spectrogram":true, "text": [ { "title": "ITA-emotion", diff --git a/docs/recorderServer.py b/docs/recorderServer.py index c543baae..47549eb7 100644 --- a/docs/recorderServer.py +++ b/docs/recorderServer.py @@ -29,22 +29,32 @@ app.debug = True def static_dir(path): return send_from_directory("../docs", path) +@app.route('/', methods=['GET']) +def redirect_to_index(): + return send_from_directory("../frontend/dist", 'index.html') + +CORS(app, resources={r"/*": {"origins": "*"}}) @app.route('/api/voice///', methods=['POST']) def post_voice(title, prefix, index): - filename = f"{prefix}{index:03}.zip" - data_dir = os.path.join(DATA_ROOT, title) - os.makedirs(data_dir,exist_ok=True) - fullpath = os.path.join(data_dir, filename) - data = base64.b64decode(request.json['data']) - f = open(fullpath, 'wb') - f.write(data) - f.close() - data = { - "message":"OK" - } - return jsonify(data) - + try: + filename = f"{prefix}{index:03}.zip" + data_dir = os.path.join(DATA_ROOT, title) + os.makedirs(data_dir,exist_ok=True) + fullpath = os.path.join(data_dir, filename) + data = base64.b64decode(request.json['data']) + f = open(fullpath, 'wb') + f.write(data) + f.close() + data = { + "message":"OK" + } + return jsonify(data) + except Exception as e: + print("REQUEST PROCESSING!!!! EXCEPTION!!!", e) + print(traceback.format_exc()) + return str(e) + @app.route('/api/voice///', methods=['GET']) def get_voice(title, prefix, index): filename = f"{prefix}{index:03}.zip" @@ -67,7 +77,6 @@ def get_voice(title, prefix, index): } return jsonify(data) -CORS(app, resources={r"/*": {"origins": "*"}}) @app.after_request def after_request(response): diff --git a/template/setting_recorder_colab.json b/template/setting_recorder_colab.json new file mode 100644 index 00000000..52116d65 --- /dev/null +++ b/template/setting_recorder_colab.json @@ -0,0 +1,25 @@ +{ + "app_title": "voice-recorder", + "storage_type":"server", + "use_mel_spectrogram":true, + "text": [ + { + "title": "ITA-emotion", + "wavPrefix": "emotion", + "file": "./assets/text/ITA_emotion_all.txt", + "file_hira": "./assets/text/ITA_emotion_all_hira.txt" + }, + { + "title": "ITA-recitation", + "wavPrefix": "recitation", + "file": "./assets/text/ITA_recitation_all.txt", + "file_hira": "./assets/text/ITA_recitation_all_hira.txt" + }, + { + "title": "wagahaiwa", + "wavPrefix": "wagahaiwa", + "file": "./assets/text/wagahaiwa.txt", + "file_hira": "./assets/text/wagahaiwa_hira.txt" + } + ] +}