From a5e4aa13005a838e48f69245dcb7e24791cf0869 Mon Sep 17 00:00:00 2001 From: Chingfeng Li Date: Tue, 18 Nov 2025 14:37:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E8=AF=AD=E9=9F=B3?= =?UTF-8?q?=E5=8C=85=E5=8F=91=E9=80=81=E6=9B=B4=E6=96=B0client=5Fis=5Fspea?= =?UTF-8?q?king=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/handle/sendAudioHandle.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main/xiaozhi-server/core/handle/sendAudioHandle.py b/main/xiaozhi-server/core/handle/sendAudioHandle.py index aa11ebb2..66e52c51 100644 --- a/main/xiaozhi-server/core/handle/sendAudioHandle.py +++ b/main/xiaozhi-server/core/handle/sendAudioHandle.py @@ -145,6 +145,7 @@ async def sendAudio(conn, audios, frame_duration=60): else: # 直接发送opus数据包,不添加头部 await conn.websocket.send(audios) + conn.client_is_speaking = True # 更新流控状态 flow_control["packet_count"] += 1 @@ -168,6 +169,7 @@ async def sendAudio(conn, audios, frame_duration=60): else: # 直接发送预缓冲包,不添加头部 await conn.websocket.send(audios[i]) + conn.client_is_speaking = True remaining_audios = audios[pre_buffer_frames:] # 播放剩余音频帧 @@ -201,6 +203,8 @@ async def sendAudio(conn, audios, frame_duration=60): # 直接发送opus数据包,不添加头部 await conn.websocket.send(opus_packet) + conn.client_is_speaking = True + play_position += frame_duration @@ -255,5 +259,4 @@ async def send_stt_message(conn, text): await conn.websocket.send( json.dumps({"type": "stt", "text": stt_text, "session_id": conn.session_id}) ) - conn.client_is_speaking = True await send_tts_message(conn, "start") From bbab4ebc86c8e8aba266b24d2e0698913265f48a Mon Sep 17 00:00:00 2001 From: Chingfeng Li Date: Tue, 18 Nov 2025 15:00:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E5=8F=91=E9=80=81?= =?UTF-8?q?=E7=9A=84=E5=BC=80=E5=A7=8B=E5=92=8C=E7=BB=93=E5=B0=BE=E4=BB=85?= =?UTF-8?q?=E4=B8=8ETTS=E7=9B=B8=E5=85=B3=EF=BC=8C=E4=B8=8D=E5=85=B3?= =?UTF-8?q?=E5=BF=83LLM=EF=BC=9BLLM=E8=B0=83=E7=94=A8MCP=E6=97=B6=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E6=B6=88=E6=81=AF=E4=BC=9A=E5=BC=95=E5=8F=91=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/handle/sendAudioHandle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/xiaozhi-server/core/handle/sendAudioHandle.py b/main/xiaozhi-server/core/handle/sendAudioHandle.py index 66e52c51..d517cdb9 100644 --- a/main/xiaozhi-server/core/handle/sendAudioHandle.py +++ b/main/xiaozhi-server/core/handle/sendAudioHandle.py @@ -23,7 +23,7 @@ async def sendAudioMessage(conn, sentenceType, audios, text): conn.logger.bind(tag=TAG).info(f"发送音频消息: {sentenceType}, {text}") # 发送结束消息(如果是最后一个文本) - if conn.llm_finish_task and sentenceType == SentenceType.LAST: + if sentenceType == SentenceType.LAST: await send_tts_message(conn, "stop", None) conn.client_is_speaking = False if conn.close_after_chat: