This commit is contained in:
wataru 2022-09-14 05:48:34 +09:00
parent 8307b89ce2
commit fddf475400
3 changed files with 49 additions and 15 deletions

View File

@ -1,7 +1,7 @@
{ {
"app_title": "voice-recorder", "app_title": "voice-recorder",
"storage_type":"local", "storage_type":"local",
"use_mel_spectrogram":false, "use_mel_spectrogram":true,
"text": [ "text": [
{ {
"title": "ITA-emotion", "title": "ITA-emotion",

View File

@ -29,9 +29,15 @@ app.debug = True
def static_dir(path): def static_dir(path):
return send_from_directory("../docs", 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/<string:title>/<string:prefix>/<int:index>', methods=['POST']) @app.route('/api/voice/<string:title>/<string:prefix>/<int:index>', methods=['POST'])
def post_voice(title, prefix, index): def post_voice(title, prefix, index):
try:
filename = f"{prefix}{index:03}.zip" filename = f"{prefix}{index:03}.zip"
data_dir = os.path.join(DATA_ROOT, title) data_dir = os.path.join(DATA_ROOT, title)
os.makedirs(data_dir,exist_ok=True) os.makedirs(data_dir,exist_ok=True)
@ -44,6 +50,10 @@ def post_voice(title, prefix, index):
"message":"OK" "message":"OK"
} }
return jsonify(data) return jsonify(data)
except Exception as e:
print("REQUEST PROCESSING!!!! EXCEPTION!!!", e)
print(traceback.format_exc())
return str(e)
@app.route('/api/voice/<string:title>/<string:prefix>/<int:index>', methods=['GET']) @app.route('/api/voice/<string:title>/<string:prefix>/<int:index>', methods=['GET'])
def get_voice(title, prefix, index): def get_voice(title, prefix, index):
@ -67,7 +77,6 @@ def get_voice(title, prefix, index):
} }
return jsonify(data) return jsonify(data)
CORS(app, resources={r"/*": {"origins": "*"}})
@app.after_request @app.after_request
def after_request(response): def after_request(response):

View File

@ -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"
}
]
}