diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py index b99d862c..fc674527 100644 --- a/main/xiaozhi-server/core/connection.py +++ b/main/xiaozhi-server/core/connection.py @@ -241,16 +241,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)