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: