-
Notifications
You must be signed in to change notification settings - Fork 19
/
audio_server.py
44 lines (32 loc) · 1.52 KB
/
audio_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import argparse
import flask
import os
from flask import Flask, request, send_from_directory
from cnn_melspec import build_model, infer
model_path = "/home/zfhu/playground/DSP/project/save/checkpoint.ptr"
"""
使用chrome进行测试时,如果服务端不是host在localhost上,会导致getUserMedia不可用(懒得搞https),所以要在信赖模式下启动chrome
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --unsafely-treat-insecure-origin-as-secure="http://10.141.208.102" --user-data-dir="temp"
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --unsafely-treat-insecure-origin-as-secure="http://10.141.208.102:22339" --user-data-dir="temp2"
"""
if __name__ == "__main__":
argparser = argparse.ArgumentParser()
args = argparser.parse_args()
app = flask.Flask(__name__, static_folder='interface')
app.debug = True
model, __ = build_model(model_path)
@app.route('/', methods=['POST', 'GET'])
def home():
return send_from_directory('interface', 'index.html')
@app.route('/save-record', methods=['POST'])
def save_record():
file = flask.request.files['file']
app.logger.debug(file.filename)
os.makedirs("upload", exist_ok=True)
save_to = "upload/{}".format(file.filename)
file.save(save_to)
return infer(model, save_to)
@app.route('/js/<path:path>')
def send_js(path):
return send_from_directory('interface/js', path)
app.run(host="0.0.0.0", port=22339)