在家开发了btn按钮样式2

This commit is contained in:
终究是寂寞
2026-03-03 23:51:42 +08:00
parent 420b9a9871
commit 7947d47683
7 changed files with 132 additions and 34 deletions
+1
View File
@@ -2,6 +2,7 @@
git 地址:https://github.com/modelscope/FunASR/blob/main/runtime/docs/SDK_tutorial_online_zh.md#html-client
docker pull registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-online-cpu-0.1.12
docker run -p 10096:10095 -it --privileged=true -v $PWD/funasr-runtime-resources/models:/workspace/models registry.home.tymas.cn:8000/funasr_repo/funasr:funasr-runtime-sdk-online-cpu-0.1.12
docker exec -it 367797c69268b2c68f1443aa0f8dcb5d5ac01355dbdd06fa6e18758415506c8f bash
+1 -1
View File
@@ -6,7 +6,7 @@ LOG_LEVEL=INFO
LOG_FILE=logs/app.log
# ASR服务配置
ASR_HOST=10.10.10.202
ASR_HOST=10.10.10.249
ASR_PORT=10096
ASR_TIMEOUT=30 # 超时时间(秒)
ASR_RETRY_TIMES=2 # 重试次数
+1 -1
View File
@@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
</content>
<orderEntry type="jdk" jdkName="audio-ai-chat" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.14 (audio_ai_chat)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="python" />
</component>
+1 -1
View File
@@ -3,5 +3,5 @@
<component name="Black">
<option name="sdkName" value="Python 3.13 (audio_ai_chat)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="audio-ai-chat" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.14 (audio_ai_chat)" project-jdk-type="Python SDK" />
</project>
@@ -149,44 +149,44 @@ class WebSocketConnectionManager:
# 解包并验证包类型
msg_type, _, identity_data = ProtocolCodec.unpack(ping_packet)
if msg_type != MessageType.IDENTITY:
error_msg = f"连接 {client_id} 首个包类型错误"
logger.error(error_msg)
error_packet = ProtocolCodec.pack(
MessageType.ERROR, {"code": 4001, "message": "非法请求:首个包必须是身份校验包"}
)
await websocket.send_bytes(error_packet)
raise ValueError(error_msg)
# if msg_type != MessageType.IDENTITY:
# error_msg = f"连接 {client_id} 首个包类型错误"
# logger.error(error_msg)
# error_packet = ProtocolCodec.pack(
# MessageType.ERROR, {"code": 4001, "message": "非法请求:首个包必须是身份校验包"}
# )
# await websocket.send_bytes(error_packet)
# raise ValueError(error_msg)
# 校验身份信息
user_id = identity_data.get("user_id")
token = identity_data.get("token")
name = identity_data.get("name") or f"用户{user_id}"
if not all([user_id, token]):
error_msg = f"连接 {client_id} 身份信息不完整"
logger.error(error_msg)
error_packet = ProtocolCodec.pack(
MessageType.ERROR, {"code": 4003, "message": "身份信息不完整:必须包含user_id和token"}
)
await websocket.send_bytes(error_packet)
raise ValueError(error_msg)
# user_id = identity_data.get("user_id")
# token = identity_data.get("token")
# name = identity_data.get("name") or f"用户{user_id}"
# if not all([user_id, token]):
# error_msg = f"连接 {client_id} 身份信息不完整"
# logger.error(error_msg)
# error_packet = ProtocolCodec.pack(
# MessageType.ERROR, {"code": 4003, "message": "身份信息不完整:必须包含user_id和token"}
# )
# await websocket.send_bytes(error_packet)
# raise ValueError(error_msg)
# 创建/获取连接上下文
context = ConnectionContext(client_id=client_id)
context.websocket = websocket
context.set_user_info(token, user_id, name)
# context.set_user_info(token, user_id, name)
# 响应身份校验成功
success_packet = ProtocolCodec.pack(
MessageType.IDENTITY,
{
"code": 200,
"message": "身份校验成功,连接已就绪",
"data": {"client_id": client_id, "user_id": user_id, "name": name}
}
)
await websocket.send_bytes(success_packet)
logger.info(f"用户 {user_id}{name})身份校验通过(client_id: {client_id}")
return context
# success_packet = ProtocolCodec.pack(
# MessageType.IDENTITY,
# {
# "code": 200,
# "message": "身份校验成功,连接已就绪",
# "data": {"client_id": client_id, "user_id": user_id, "name": name}
# }
# )
# await websocket.send_bytes(success_packet)
# logger.info(f"用户 {user_id}{name})身份校验通过(client_id: {client_id}")
# return context
# ------------------------------
# 核心连接处理逻辑(修复启动时机、优化退出流程)
+97
View File
@@ -3121,3 +3121,100 @@
2025-12-04 10:17:34.743 | INFO | audio_ai_chat.core.websocket_handler:_send_worker:129 - 客户端 2156400945104 发送协程已退出
2025-12-04 10:17:34.743 | INFO | audio_ai_chat.core.websocket_handler:_unregister_connection:68 - 客户端 2156400945104 注销成功,当前活跃连接数:0
2025-12-04 10:17:34.743 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2156400945104 连接清理完成
2026-03-03 23:00:41.094 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 2453862587504 已接受,等待身份信息(5秒超时),当前连接数: 0
2026-03-03 23:00:43.988 | ERROR | audio_ai_chat.core.websocket_handler:connect:154 - 连接 2453862587504 首个包类型错误
2026-03-03 23:00:43.989 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 2453862587504 处理异常:连接 2453862587504 首个包类型错误
2026-03-03 23:00:43.989 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 2453862587504 开始清理连接
2026-03-03 23:00:43.990 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2453862587504 连接清理完成
2026-03-03 23:04:12.464 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 2453865959216 已接受,等待身份信息(5秒超时),当前连接数: 0
2026-03-03 23:04:16.053 | ERROR | audio_ai_chat.core.websocket_handler:connect:154 - 连接 2453865959216 首个包类型错误
2026-03-03 23:04:16.054 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 2453865959216 处理异常:连接 2453865959216 首个包类型错误
2026-03-03 23:04:16.054 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 2453865959216 开始清理连接
2026-03-03 23:04:16.055 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2453865959216 连接清理完成
2026-03-03 23:05:03.032 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 2453862530128 已接受,等待身份信息(5秒超时),当前连接数: 0
2026-03-03 23:05:05.137 | ERROR | audio_ai_chat.core.websocket_handler:connect:154 - 连接 2453862530128 首个包类型错误
2026-03-03 23:05:05.138 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 2453862530128 处理异常:连接 2453862530128 首个包类型错误
2026-03-03 23:05:05.138 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 2453862530128 开始清理连接
2026-03-03 23:05:05.139 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2453862530128 连接清理完成
2026-03-03 23:06:06.079 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 1266493890768 已接受,等待身份信息(5秒超时),当前连接数: 0
2026-03-03 23:06:08.821 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 1266493890768 处理异常:name 'token' is not defined
2026-03-03 23:06:08.821 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=1266493890768user_id=None,对话历史条数=0
2026-03-03 23:06:08.821 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 1266493890768 开始清理连接
2026-03-03 23:06:08.822 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 1266493890768 连接清理完成
2026-03-03 23:06:23.761 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 2434430099664 已接受,等待身份信息(5秒超时),当前连接数: 0
2026-03-03 23:06:25.573 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 2434430099664 处理异常:name 'user_id' is not defined
2026-03-03 23:06:25.573 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=2434430099664user_id=None,对话历史条数=0
2026-03-03 23:06:25.574 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 2434430099664 开始清理连接
2026-03-03 23:06:25.575 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2434430099664 连接清理完成
2026-03-03 23:06:49.519 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 2026120028368 已接受,等待身份信息(5秒超时),当前连接数: 0
2026-03-03 23:06:51.681 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=2026120028368user_id=None,对话历史条数=0
2026-03-03 23:06:51.682 | INFO | audio_ai_chat.core.websocket_handler:_register_connection:58 - 客户端 2026120028368 注册成功,当前活跃连接数:1
2026-03-03 23:06:51.682 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 2026120028368 处理异常:'NoneType' object has no attribute 'asr_callback'
2026-03-03 23:06:51.683 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 2026120028368 开始清理连接
2026-03-03 23:06:51.683 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2026120028368 连接清理完成
2026-03-03 23:07:09.016 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 2026120090448 已接受,等待身份信息(5秒超时),当前连接数: 1
2026-03-03 23:07:13.443 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=2026120090448user_id=None,对话历史条数=0
2026-03-03 23:07:13.443 | INFO | audio_ai_chat.core.websocket_handler:_register_connection:58 - 客户端 2026120090448 注册成功,当前活跃连接数:2
2026-03-03 23:07:13.444 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 2026120090448 处理异常:'NoneType' object has no attribute 'asr_callback'
2026-03-03 23:07:13.444 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 2026120090448 开始清理连接
2026-03-03 23:07:13.445 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2026120090448 连接清理完成
2026-03-03 23:19:25.979 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 1834826866896 已接受,等待身份信息(5秒超时),当前连接数: 0
2026-03-03 23:19:27.087 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=1834826866896user_id=None,对话历史条数=0
2026-03-03 23:19:27.088 | INFO | audio_ai_chat.core.websocket_handler:_register_connection:58 - 客户端 1834826866896 注册成功,当前活跃连接数:1
2026-03-03 23:19:27.089 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 1834826866896 处理异常:'NoneType' object has no attribute 'asr_callback'
2026-03-03 23:19:27.089 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 1834826866896 开始清理连接
2026-03-03 23:19:27.090 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 1834826866896 连接清理完成
2026-03-03 23:19:31.605 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 1834826928368 已接受,等待身份信息(5秒超时),当前连接数: 1
2026-03-03 23:19:32.022 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=1834826928368user_id=None,对话历史条数=0
2026-03-03 23:19:32.023 | INFO | audio_ai_chat.core.websocket_handler:_register_connection:58 - 客户端 1834826928368 注册成功,当前活跃连接数:2
2026-03-03 23:19:32.024 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 1834826928368 处理异常:'NoneType' object has no attribute 'asr_callback'
2026-03-03 23:19:32.024 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 1834826928368 开始清理连接
2026-03-03 23:19:32.025 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 1834826928368 连接清理完成
2026-03-03 23:19:36.980 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 1834826832432 已接受,等待身份信息(5秒超时),当前连接数: 2
2026-03-03 23:19:37.354 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=1834826832432user_id=None,对话历史条数=0
2026-03-03 23:19:37.354 | INFO | audio_ai_chat.core.websocket_handler:_register_connection:58 - 客户端 1834826832432 注册成功,当前活跃连接数:3
2026-03-03 23:19:37.355 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 1834826832432 处理异常:获取ASR连接失败
2026-03-03 23:19:37.355 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 1834826832432 开始清理连接
2026-03-03 23:19:37.356 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 1834826832432 连接清理完成
2026-03-03 23:19:39.277 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 1834830534032 已接受,等待身份信息(5秒超时),当前连接数: 3
2026-03-03 23:19:39.642 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=1834830534032user_id=None,对话历史条数=0
2026-03-03 23:19:39.642 | INFO | audio_ai_chat.core.websocket_handler:_register_connection:58 - 客户端 1834830534032 注册成功,当前活跃连接数:4
2026-03-03 23:19:39.643 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 1834830534032 处理异常:获取ASR连接失败
2026-03-03 23:19:39.643 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 1834830534032 开始清理连接
2026-03-03 23:19:39.644 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 1834830534032 连接清理完成
2026-03-03 23:19:51.630 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 2491837980880 已接受,等待身份信息(5秒超时),当前连接数: 0
2026-03-03 23:19:51.968 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=2491837980880user_id=None,对话历史条数=0
2026-03-03 23:19:51.969 | INFO | audio_ai_chat.core.websocket_handler:_register_connection:58 - 客户端 2491837980880 注册成功,当前活跃连接数:1
2026-03-03 23:19:51.969 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 2491837980880 处理异常:'NoneType' object has no attribute 'asr_callback'
2026-03-03 23:19:51.970 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 2491837980880 开始清理连接
2026-03-03 23:19:51.970 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2491837980880 连接清理完成
2026-03-03 23:36:11.268 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 2131690795600 已接受,等待身份信息(5秒超时),当前连接数: 0
2026-03-03 23:36:13.786 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=2131690795600user_id=None,对话历史条数=0
2026-03-03 23:36:13.787 | INFO | audio_ai_chat.core.websocket_handler:_register_connection:58 - 客户端 2131690795600 注册成功,当前活跃连接数:1
2026-03-03 23:36:13.787 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 2131690795600 处理异常:'NoneType' object has no attribute 'asr_callback'
2026-03-03 23:36:13.788 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 2131690795600 开始清理连接
2026-03-03 23:36:13.788 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2131690795600 连接清理完成
2026-03-03 23:37:33.743 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 2131690856544 已接受,等待身份信息(5秒超时),当前连接数: 1
2026-03-03 23:37:37.548 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=2131690856544user_id=None,对话历史条数=0
2026-03-03 23:37:37.549 | INFO | audio_ai_chat.core.websocket_handler:_register_connection:58 - 客户端 2131690856544 注册成功,当前活跃连接数:2
2026-03-03 23:37:37.549 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 2131690856544 处理异常:'NoneType' object has no attribute 'asr_callback'
2026-03-03 23:37:37.550 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 2131690856544 开始清理连接
2026-03-03 23:37:37.550 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2131690856544 连接清理完成
2026-03-03 23:37:38.339 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 2131690757520 已接受,等待身份信息(5秒超时),当前连接数: 2
2026-03-03 23:37:39.073 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=2131690757520user_id=None,对话历史条数=0
2026-03-03 23:37:39.073 | INFO | audio_ai_chat.core.websocket_handler:_register_connection:58 - 客户端 2131690757520 注册成功,当前活跃连接数:3
2026-03-03 23:37:39.074 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 2131690757520 处理异常:获取ASR连接失败
2026-03-03 23:37:39.075 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 2131690757520 开始清理连接
2026-03-03 23:37:39.075 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2131690757520 连接清理完成
2026-03-03 23:37:41.433 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 2131694460160 已接受,等待身份信息(5秒超时),当前连接数: 3
2026-03-03 23:37:42.164 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=2131694460160user_id=None,对话历史条数=0
2026-03-03 23:37:42.165 | INFO | audio_ai_chat.core.websocket_handler:_register_connection:58 - 客户端 2131694460160 注册成功,当前活跃连接数:4
2026-03-03 23:37:42.166 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 2131694460160 处理异常:获取ASR连接失败
2026-03-03 23:37:42.166 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 2131694460160 开始清理连接
2026-03-03 23:37:42.166 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2131694460160 连接清理完成
2026-03-03 23:37:52.765 | INFO | audio_ai_chat.core.websocket_handler:connect:134 - 连接 2131694583888 已接受,等待身份信息(5秒超时),当前连接数: 4
2026-03-03 23:37:55.343 | INFO | audio_ai_chat.core.connection:close:316 - 连接上下文已关闭:client_id=2131694583888user_id=None,对话历史条数=0
2026-03-03 23:37:55.343 | INFO | audio_ai_chat.core.websocket_handler:_register_connection:58 - 客户端 2131694583888 注册成功,当前活跃连接数:5
2026-03-03 23:37:55.344 | ERROR | audio_ai_chat.core.websocket_handler:handle_connection:248 - 客户端 2131694583888 处理异常:获取ASR连接失败
2026-03-03 23:37:55.344 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:252 - 客户端 2131694583888 开始清理连接
2026-03-03 23:37:55.345 | INFO | audio_ai_chat.core.websocket_handler:handle_connection:279 - 客户端 2131694583888 连接清理完成