修复两次VAD提示音的BUG,修复未close直接断联websocket问题,修复长对话模式 短按按键重新录音 TTS仍播报的问题,修复单对话模式 长按按键 无法打断TT...
authorTimekeeperPL <1624952103@qq.com>
Wed, 27 May 2026 07:38:11 +0000 (15:38 +0800)
committerTimekeeperPL <1624952103@qq.com>
Wed, 27 May 2026 07:38:11 +0000 (15:38 +0800)
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session_io.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session_media.py

index 12737c1..0ad78cb 100644 (file)
@@ -1056,6 +1056,21 @@ class VCSessionIoMixin:
                                 self._ptt_await_server = 0
                             except Exception:
                                 pass
+                            # 单对话:松手后首轮 tts.started 须起播(勿沿用录音期的 drop 标志)
+                            try:
+                                if (
+                                    self._vc_is_ptt_mode()
+                                    and getattr(self, "VC_record_state_flag", 0) == 0
+                                    and not (
+                                        hasattr(self, "_ptt_in_interrupt_wait")
+                                        and self._ptt_in_interrupt_wait()
+                                    )
+                                ):
+                                    self._drop_tts_audio = 0
+                                    self.is_ruppt_tts = 0
+                                    self._ptt_interrupt_active = 0
+                            except Exception:
+                                pass
                             self._server_vad_silence = 1
                             self._turn_has_tts_started = 1
                             try:
index 98f6430..dd6988e 100644 (file)
@@ -1218,6 +1218,16 @@ class VCSessionMediaMixin:
             if getattr(self, "VC_mode", -1) == 1:
                 self._ptt_led_lock_listening = 0
                 self._ptt_interrupt_active = 0
+                # 松手等 LLM/TTS:须允许本轮下行播放(打断/canceled 残留 drop 勿带入)
+                if not ptt_silent:
+                    self._drop_tts_audio = 0
+                    self.is_ruppt_tts = 0
+                    if getattr(self, "_intr", None) is not None:
+                        try:
+                            self._intr.drop_tts = 0
+                            self._intr.ruppt_tts = 0
+                        except Exception:
+                            pass
                 if ptt_silent:
                     # ptt_begin 清理残留录音:用户仍按住,勿进思考态/勿清长按
                     self._ptt_await_server = 0
@@ -1607,8 +1617,9 @@ class VCSessionMediaMixin:
                         "已切换到单对话模式" if int(getattr(self, "VC_mode", 0)) == 1
                         else "已切换到长对话模式"
                     )
-            if ms_hint:
-                self.AI_TTS_str = ms_hint
+            saved_tts = ms_hint or ""
+            if saved_tts:
+                self.AI_TTS_str = saved_tts
             if is_close_VC != None:
                 self.Close_flag = is_close_VC
             try:
@@ -1629,7 +1640,7 @@ class VCSessionMediaMixin:
                     "find_device", "asr_empty_hint",
                 )
                 # 单对话 notify:设计稿仅 ASR complete 后亮思考灯;提示音/模式切换保持 idle
-                if is_close_VC or ptt_mode or notify_kind:
+                if is_close_VC or notify_kind:
                     prefer_off = 1 if (ptt_mode or k in ("prompt", "boot_prompt")) else 0
                     self._vc_publish_led(
                         "idle", "play_tts_cb/notify", prefer_off=prefer_off)
@@ -1640,14 +1651,28 @@ class VCSessionMediaMixin:
             self.AI_ASR_send_buf_len = 0
             self._uplink_request_stop("play_tts_cb")
             self.Close_reconnect()
+            # Close() 会清空 AI_TTS_str;须在重连后恢复,否则 started 无 OP_SYNTHESIS(PTT_HINT 无声)
             try:
-                if k in ("mode_switch_long", "mode_switch_ptt") and ms_hint:
-                    self.AI_TTS_str = ms_hint
-                    self._pending_tts_kind = k
-                    self._last_tts_kind = k
+                if saved_tts:
+                    self.AI_TTS_str = saved_tts
+                    if k:
+                        self._pending_tts_kind = k
+                        self._last_tts_kind = k
             except Exception:
                 pass
             self.AI_VC_start()
+            try:
+                if (
+                    saved_tts
+                    and getattr(self, "_vc_session_started", 0) == 1
+                    and getattr(self, "_tts_pending", 0) == 0
+                ):
+                    EventMesh.publish(
+                        "publish_AI_btnInfo",
+                        {"func": self.AI_client_VC_synthesis},
+                    )
+            except Exception:
+                pass
             
             # EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})
             # EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_deconnect_VC})