From 6a213fe65536a97c21a2054347f1098aed9397ab Mon Sep 17 00:00:00 2001 From: martsforever Date: Sun, 2 Nov 2025 16:42:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=86=E5=89=8D=E7=AB=AF=E5=BD=95?= =?UTF-8?q?=E9=9F=B3=E8=BD=AC=E5=8F=91=E7=BB=99=E7=99=BE=E7=82=BCwebsocket?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/add_websocket_voice_recognise_route.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controller/add_websocket_voice_recognise_route.py b/app/controller/add_websocket_voice_recognise_route.py index 309b8ce..e690935 100644 --- a/app/controller/add_websocket_voice_recognise_route.py +++ b/app/controller/add_websocket_voice_recognise_route.py @@ -2,6 +2,7 @@ import json import base64 import os import struct +import asyncio import websockets import time @@ -108,7 +109,6 @@ def add_websocket_voice_recognise_route(app: FastAPI): print(f"从百炼转发到客户端时出错: {e}") # 并发运行两个任务 - import asyncio await asyncio.gather( forward_to_bailing(), forward_to_client(), @@ -118,8 +118,9 @@ def add_websocket_voice_recognise_route(app: FastAPI): except Exception as e: print(f"WebSocket连接错误: {e}") finally: + print("finally ===>>>>>>>>>>>>>>>>>>>>>>>>>>>") # 清理连接 - if bailing_socket and not bailing_socket.closed: + if bailing_socket and bailing_socket.open: await bailing_socket.close() if receive_socket.application_state != WebSocketState.DISCONNECTED: