diff --git a/main/xiaozhi-server/core/handle/helloHandle.py b/main/xiaozhi-server/core/handle/helloHandle.py index a4220d5a..129b0aa7 100644 --- a/main/xiaozhi-server/core/handle/helloHandle.py +++ b/main/xiaozhi-server/core/handle/helloHandle.py @@ -1,5 +1,6 @@ import time import json +import uuid import random import asyncio from core.utils.dialogue import Message @@ -105,6 +106,9 @@ async def checkWakeupWords(conn, text): # 播放唤醒词回复 conn.client_abort = False + # 将唤醒词回复视为新会话,生成新的 sentence_id,确保流控器重置 + conn.sentence_id = str(uuid.uuid4().hex) + conn.logger.bind(tag=TAG).info(f"播放唤醒词回复: {response.get('text')}") await sendAudioMessage(conn, SentenceType.FIRST, opus_packets, response.get("text")) await sendAudioMessage(conn, SentenceType.LAST, [], None) diff --git a/main/xiaozhi-server/core/handle/sendAudioHandle.py b/main/xiaozhi-server/core/handle/sendAudioHandle.py index e60ce412..323056d1 100644 --- a/main/xiaozhi-server/core/handle/sendAudioHandle.py +++ b/main/xiaozhi-server/core/handle/sendAudioHandle.py @@ -148,10 +148,9 @@ def _get_or_create_rate_controller(conn, frame_duration, is_single_packet): or rate_controller.pending_send_task.done() ): need_reset = True - # 流式单包模式下, sentence_id 变化, 需要重置 + # 当sentence_id 变化,需要重置 elif ( - is_single_packet - and getattr(conn, "audio_flow_control", {}).get("sentence_id") + getattr(conn, "audio_flow_control", {}).get("sentence_id") != conn.sentence_id ): need_reset = True