From 220e4fab27b7f419b3e89e2f2d28ae789aac09d7 Mon Sep 17 00:00:00 2001
From: wangzhibo <wangzhibo@shsening.com>
Date: 星期四, 08 十月 2026 16:29:55 +0800
Subject: [PATCH] 5种场景模式家长端ok

---
 xiaozhi-esp32-server/main/xiaozhi-server/core/handle/sendAudioHandle.py |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/xiaozhi-esp32-server/main/xiaozhi-server/core/handle/sendAudioHandle.py b/xiaozhi-esp32-server/main/xiaozhi-server/core/handle/sendAudioHandle.py
index c2ecdb9..ac7c73a 100644
--- a/xiaozhi-esp32-server/main/xiaozhi-server/core/handle/sendAudioHandle.py
+++ b/xiaozhi-esp32-server/main/xiaozhi-server/core/handle/sendAudioHandle.py
@@ -294,6 +294,9 @@
     message = {"type": "tts", "state": state, "session_id": conn.session_id}
     if text is not None:
         message["text"] = textUtils.check_emoji(text)
+    # 鍐嶈/瓒呮椂缁撴潫锛氳澶囨敹鍒� stop 鍚庡簲鐩存帴 idle 绛夊敜閱掞紝涓嶈鍏堝洖 listening銆�
+    if state == "stop" and getattr(conn, "close_after_chat", False):
+        message["session_end"] = True
 
     # TTS鎾斁缁撴潫
     if state == "stop":
@@ -321,6 +324,10 @@
 
     # 鍙戦�佹秷鎭埌瀹㈡埛绔�
     await conn.websocket.send(json.dumps(message))
+    if state == "stop":
+        from core.app_runtime.runtime import maybe_flush_pending_play_after_tts
+
+        await maybe_flush_pending_play_after_tts(conn)
 
 
 async def send_stt_message(conn: "ConnectionHandler", text):

--
Gitblit v1.9.1