From 95a678bb18a6de66f5a72425f3ebee10d3fc53a1 Mon Sep 17 00:00:00 2001 From: Sakura-RanChen <1908198662@qq.com> Date: Fri, 27 Jun 2025 16:39:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=80=E5=87=BA=E8=BF=87=E5=BF=AB?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/connection.py | 10 +++------- main/xiaozhi-server/core/handle/sendAudioHandle.py | 6 ++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py index 3ad94592..d3a5210f 100644 --- a/main/xiaozhi-server/core/connection.py +++ b/main/xiaozhi-server/core/connection.py @@ -243,16 +243,12 @@ class ConnectionHandler: # 立即关闭连接,不等待记忆保存完成 await self.close(ws) - async def reset_timeout(self): - """重置超时计时器""" - if self.timeout_task: - self.timeout_task.cancel() - self.timeout_task = asyncio.create_task(self._check_timeout()) - async def _route_message(self, message): """消息路由""" # 重置超时计时器 - await self.reset_timeout() + if self.timeout_task: + self.timeout_task.cancel() + self.timeout_task = asyncio.create_task(self._check_timeout()) if isinstance(message, str): await handleTextMessage(self, message) diff --git a/main/xiaozhi-server/core/handle/sendAudioHandle.py b/main/xiaozhi-server/core/handle/sendAudioHandle.py index 2bf55e65..6e3bca62 100644 --- a/main/xiaozhi-server/core/handle/sendAudioHandle.py +++ b/main/xiaozhi-server/core/handle/sendAudioHandle.py @@ -92,10 +92,8 @@ async def sendAudio(conn, audios, pre_buffer=True): if conn.client_abort: break - # 每分钟重置一次计时器 - if time.perf_counter() - last_reset_time > 60: - await conn.reset_timeout() - last_reset_time = time.perf_counter() + # 重置没有声音的状态 + conn.client_no_voice_last_time = 0.0 # 计算预期发送时间 expected_time = start_time + (play_position / 1000)