From 79b933e66e29980c6242c78936ca596b6037427d Mon Sep 17 00:00:00 2001 From: yueliuli <1628111725@qq.com> Date: Wed, 6 May 2026 17:09:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=B1=BB=E5=9E=8B=E6=94=B9?= =?UTF-8?q?=E4=B8=BAget=EF=BC=8C=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ++++++- server.py | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index eaec85d..cdeef75 100644 --- a/README.md +++ b/README.md @@ -33,4 +33,9 @@ main.py中的main函数接受文件名或文件夹,路径为相对于input的路 例如如果input目录下有一个文件夹test,文件夹下有一个文件1.mp3, -则main.py中的main函数接受的路径为test/1.mp3或test \ No newline at end of file +则main.py中的main函数接受的路径为test/1.mp3或test + +# 使用方法 +http://localhost:5000/api/recognize?path=1.avi 文件推理 + +http://localhost:5000/api/result?path=1.avi 获取文件推理结果 diff --git a/server.py b/server.py index 7556ec5..5bf3cc3 100644 --- a/server.py +++ b/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 服务器(无超时限制)")