接口类型改为get,更新readme
This commit is contained in:
parent
6530c80149
commit
79b933e66e
|
|
@ -33,4 +33,9 @@ main.py中的main函数接受文件名或文件夹,路径为相对于input的路
|
|||
|
||||
例如如果input目录下有一个文件夹test,文件夹下有一个文件1.mp3,
|
||||
|
||||
则main.py中的main函数接受的路径为test/1.mp3或test
|
||||
则main.py中的main函数接受的路径为test/1.mp3或test
|
||||
|
||||
# 使用方法
|
||||
http://localhost:5000/api/recognize?path=1.avi 文件推理
|
||||
|
||||
http://localhost:5000/api/result?path=1.avi 获取文件推理结果
|
||||
|
|
|
|||
10
server.py
10
server.py
|
|
@ -87,16 +87,16 @@ task_running = {}
|
|||
task_timeout = 600 # 10 分钟超时(秒)
|
||||
|
||||
|
||||
@app.route('/api/recognize', methods=['POST'])
|
||||
@app.route('/api/recognize', methods=['GET'])
|
||||
def recognize():
|
||||
"""文件推理 - 调用 main.py 的 main 函数"""
|
||||
task_id = str(uuid.uuid4())
|
||||
task_running[task_id] = True
|
||||
|
||||
try:
|
||||
|
||||
# 从请求参数获取路径(只接受文件名或 input 目录下的相对路径)
|
||||
data = request.json or {}
|
||||
path = data.get('path', '')
|
||||
path = request.args.get('path', '')
|
||||
|
||||
if not path:
|
||||
return jsonify(make_response(
|
||||
|
|
@ -218,8 +218,8 @@ if __name__ == '__main__':
|
|||
print(" ASR & Speaker Diarization API Server")
|
||||
print("=" * 60)
|
||||
print("\nAPI 接口:")
|
||||
print(" POST /api/recognize - 文件推理")
|
||||
print(" POST /api/result - 获取文件推理结果")
|
||||
print(" GET /api/recognize - 文件推理")
|
||||
print(" GET /api/result - 获取文件推理结果")
|
||||
print("\n" + "=" * 60)
|
||||
print("启动服务:http://localhost:5000")
|
||||
print("使用 Waitress WSGI 服务器(无超时限制)")
|
||||
|
|
|
|||
Loading…
Reference in New Issue