From: TimekeeperPL <1624952103@qq.com> Date: Mon, 25 May 2026 09:10:02 +0000 (+0800) Subject: 优化关机记录对话模式,增加empty语音提醒,优化开录提示音播放,修复关机提示音被tts打断bug X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=a9504ca0d2867f5c1f743a10d56c486e3e379808;p=mirrors%2FASR1603_G5.git 优化关机记录对话模式,增加empty语音提醒,优化开录提示音播放,修复关机提示音被tts打断bug --- diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/products/configs/k8/default_config.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/products/configs/k8/default_config.py index 71ac4da2..bb24b9af 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/products/configs/k8/default_config.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/products/configs/k8/default_config.py @@ -175,13 +175,15 @@ POWEROFF_CMD_CLOSE_ONLY = False # 「关机」指令仅 Close,不真断电 KWS_PTT_HINT = "请您按住圆形的按钮开始讲话,讲完松开即可 " PTT_HINT = "请您按住圆形的按钮开始讲话,讲完松开即可 " +ASR_EMPTY_HINT_TTS = "我没有听清,请再说一遍" # asr.completed 无有效识别时 Notify 播报 + # ============================================================================= # 10. 开录音 / PTT 时序(对齐「录音上传与播放」设计稿) # ============================================================================= -# 无按键确认音:不按 key_prompt;仅「开始录音」播 start.mp3(非滴声) +# 无按键确认音:不按 key_prompt;仅按键/PTT 开录时播 start.mp3(自动续聊不播) # PTT idle 短按:notify 话术 PTT_HINT;长按开录:start.mp3 -RECORD_START_TONE_FILE = "U:/static/start.mp3" # 开录/打断续聊提醒(唯一本地按键相关短音) +RECORD_START_TONE_FILE = "U:/static/start.mp3" # 按键/PTT 开录提示音(非 server.started 自动开麦) RECORD_START_TONE_GAP_MS = 180 PTT_MIN_RECORD_MS = 400 diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_buttons.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_buttons.py index 1f4ab88a..426fafe1 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_buttons.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_buttons.py @@ -658,17 +658,7 @@ class AI_dev(Abstract): #print("pwk_key_long_press {}".format(self.pwk_key_long_press)) if self.pwk_key_long_press == 0: self.pwk_key_long_press = 1 - #EventMesh.publish("AI_key_long_press") - # EventMesh.publish("audio_montage_play",["zhengzaiguanji.mp3"]) - self.aud.play(1,0,'U:/static/zhengzaiguanji.mp3')#关机音频 - EventMesh.publish("set_led_state", {"battery": "empty"}) - utime.sleep_ms(2000) - self.aud.stopPlayStream() - self.aud.stopAll() - Power.powerDown() - #print("AI_key_release") - #EventMesh.publish("pwk_key_long_press") - #EventMesh.publish("publish_AI_btnInfo",{"func":self.pwk_key_Long_Press}) + EventMesh.publish("publish_AI_btnInfo", {"func": self._shutdown_tone_play_and_powerdown}) if self.pwk_key_status == 1:#松开 #print("pwk_key_timer_cb:{}".format(self.pwk_key_timer_count)) try: @@ -814,14 +804,7 @@ class AI_dev(Abstract): except Exception: allow_power_off = False if allow_power_off: - EventMesh.publish("audio_montage_play",["zhengzaiguanji.mp3"]) - #self.aud.play(1,0,'U:/static/zhengzaiguanji.mp3')#关机音频 - EventMesh.publish("set_led_state", {"battery": "empty"}) - utime.sleep_ms(2000) - self.aud.stopPlayStream() - print("stopAll:8") - self.aud.stopAll() - Power.powerDown() + EventMesh.publish("publish_AI_btnInfo", {"func": self._shutdown_tone_play_and_powerdown}) if self.KeyAI_status == 1:#松开 #print("KeyAI_timer_cb:{}".format(self.KeyAI_timer_count)) try: @@ -920,22 +903,19 @@ class AI_dev(Abstract): print("pwk_key_double_press") EventMesh.publish("pwk_key_double_press") + def _persist_vc_mode_before_powerdown(self): + try: + m = EventMesh.publish("get_vc_mode") + if m is not None: + EventMesh.publish("set_storage_config", ["VC_mode", int(m)]) + except Exception: + pass + def pwk_key_Long_Press(self,event=None,msg=None): self.check_rest_timer_count = 0 print("pwk_key_long_press!!!!!!!") print("pwk_key_long_press!!!!!!!") - - # EventMesh.publish("paly_iccid_imei") - # return - EventMesh.publish("audio_montage_play",["zhengzaiguanji.mp3"]) - #self.aud.play(1,0,'U:/static/zhengzaiguanji.mp3')#关机音频 - EventMesh.publish("set_led_state", {"battery": "empty"}) - utime.sleep_ms(3000) - self.aud.stopPlayStream() - self.aud.stopAll() - Power.powerDown() - #print("AI_key_release") - #EventMesh.publish("pwk_key_long_press") + self._shutdown_tone_play_and_powerdown() def pwk_key_release(self): self.check_rest_timer_count = 0 @@ -973,6 +953,7 @@ class AI_dev(Abstract): self.aud.stopAll() except Exception: pass + self._persist_vc_mode_before_powerdown() try: Power.powerDown() except Exception: @@ -1073,12 +1054,38 @@ class AI_dev(Abstract): try: for i in (msg or []): n = str(i) - if ("Low_power" in n) or ("didianguanji" in n): + if ( + ("Low_power" in n) + or ("didianguanji" in n) + or ("zhengzaiguanji" in n) + ): return True except Exception: pass return False + def _shutdown_tone_play_and_powerdown(self): + """关机提示音:先断 VC TTS,再播 zhengzaiguanji,最后断电。""" + self._persist_vc_mode_before_powerdown() + try: + EventMesh.publish("battery_priority_mute_vc") + except Exception: + pass + try: + EventMesh.publish("Close_VC") + except Exception: + pass + try: + utime.sleep_ms(80) + except Exception: + pass + EventMesh.publish("audio_montage_play", ["zhengzaiguanji.mp3"]) + EventMesh.publish("set_led_state", {"battery": "empty"}) + utime.sleep_ms(3000) + self.aud.stopPlayStream() + self.aud.stopAll() + Power.powerDown() + def audio_montage_play(self,event,msg): self.wakeup_BT() bat_pri = self._audio_is_battery_priority(msg) diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_fsm.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_fsm.py index 61d9937c..7432d435 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_fsm.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_fsm.py @@ -284,12 +284,12 @@ class VCStateMachine: # 例外: # - 刚切到长对话模式的提示音(mode_switch_long)不应自动开麦 # - 其它提示/提醒(prompt)不应自动开麦 - # - boot_prompt:started 阶段已跳过开麦,播完需自动进入首轮聆听(155536) + # - boot_prompt:播完仅 Close 回 idle,勿自动开麦(待机后等用户按键) # 实际开麦是否允许由 _uplink_request_start 的门控(FSM.turn / record_state 等)保证安全幂等。 try: if self.mode() == VCMode.Realtime and getattr(self.vc, "Close_flag", 0) == 0: k = getattr(self.vc, "_last_tts_kind", "") or "" - if k in ("dialog", "boot_prompt"): + if k == "dialog": # 用户短按打断(RequestToSpeak):等 canceled 再开麦,勿 play_end 抢跑 if getattr(self.vc, "_vc_pending_interrupt_uplink", 0) != 1: actions.append(("uplink_start", "local.play_end")) diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_notify.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_notify.py index 3516c108..b957e555 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_notify.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_notify.py @@ -102,6 +102,7 @@ class NotifyScheduler(object): not skip_long_uplink and getattr(vc, "VC_mode", 0) == 0 and getattr(vc, "Close_flag", 0) == 0 + and not getattr(vc, "_vc_boot_standby", 0) ): plan.append({"op": OP_LONG_UPLINK}) except Exception: diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session.py index e41fd3a1..96c67592 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session.py @@ -687,7 +687,10 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): continue if op == OP_LONG_UPLINK: try: - if getattr(self, "_long_dialogue_key_arm", 0) == 1: + if ( + getattr(self, "_long_dialogue_key_arm", 0) == 1 + and not getattr(self, "_vc_boot_standby", 0) + ): self._long_dialogue_publish_listening("server.started") except Exception: pass @@ -808,6 +811,133 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): except Exception: pass + def _vc_handle_asr_empty(self, reason="asr.completed"): + """ASR completed 无有效文本:清轮次态 + Notify 播报(与 _ptt_abort_short_record 同出口)。""" + hint = "我没有听清,请再说一遍" + try: + if "vc_config" in globals() and vc_config: + cfg = vc_config.get_attr("ASR_EMPTY_HINT_TTS", None) + if cfg is not None and str(cfg).strip(): + hint = str(cfg).strip() + except Exception: + pass + try: + print("[VC][ASR] completed empty -> clear + notify ({})".format(reason)) + except Exception: + pass + try: + self.AI_ASR_str = "" + self.AI_ASR_str_tmp = "" + self._last_asr_result_text = "" + self._asr_completed_tone_done = 0 + except Exception: + pass + if self._vc_is_long_dialogue_mode(): + self._vc_handle_asr_empty_long(hint, reason) + return + self._vc_handle_asr_empty_ptt(hint, reason) + + def _vc_handle_asr_empty_long(self, hint, reason="asr.completed"): + """长对话:空 ASR 提示播完后复用 sid 重新开麦(蓝慢闪)。""" + try: + self._vc_reopen_uplink_after_empty_hint = 0 + if ( + getattr(self, "Close_flag", 0) == 0 + and getattr(self, "AI_client_VC_isconnect", 0) == 1 + and getattr(self, "_vc_session_started", 0) == 1 + ): + self._vc_reopen_uplink_after_empty_hint = 1 + except Exception: + pass + try: + self._server_vad_silence = 0 + self._vc_defer_vad_uplink_stop = 0 + self._vc_vad_had_active_after_silence = 0 + except Exception: + pass + try: + if getattr(self, "VC_record_state_flag", 0) != 0: + self.VC_Speech_End() + except Exception: + pass + try: + if getattr(self, "AI_client_VC_isconnect", 0) == 1 and getattr( + self, "_vc_session_started", 0 + ) == 1: + self._vc_send_protocol_cancel("asr.empty") + except Exception: + pass + try: + self._pending_tts_kind = "asr_empty_hint" + self._last_tts_kind = "asr_empty_hint" + self.request_send_synthesis(hint) + print("[VC][ASR] long empty hint -> synthesis, reopen_after=1") + except Exception as e: + usys.print_exception(e) + + def _vc_handle_asr_empty_ptt(self, hint, reason="asr.completed"): + """单对话:idle + Notify(不断线重连的轻量路径仍走 play_tts)。""" + try: + self._ptt_await_server = 0 + self._ptt_audio_created = 0 + self._ptt_defer_speech_until_asr = 0 + self._ptt_record_open_ms = 0 + self.AI_key_long_press_flag = 0 + self._ptt_idle_latch = 1 + self._vc_reopen_uplink_after_empty_hint = 0 + except Exception: + pass + try: + if getattr(self, "VC_record_state_flag", 0) != 0: + self.VC_Speech_End() + except Exception: + pass + try: + if getattr(self, "AI_client_VC_isconnect", 0) == 1 and getattr( + self, "_vc_session_started", 0 + ) == 1: + self._vc_send_protocol_cancel("asr.empty") + except Exception: + pass + try: + EventMesh.publish("play_tts", [hint, 0, "prompt"]) + except Exception: + pass + try: + self._vc_publish_led("idle", "asr.empty") + except Exception: + pass + + def _vc_long_reopen_after_asr_empty_hint(self): + """长对话:空 ASR 提示 TTS 播完后重新上行(复用当前 sid)。""" + if not getattr(self, "_vc_reopen_uplink_after_empty_hint", 0): + return False + self._vc_reopen_uplink_after_empty_hint = 0 + if not self._vc_is_long_dialogue_mode(): + return False + try: + if getattr(self, "Close_flag", 0) == 1: + return False + if getattr(self, "AI_client_VC_isconnect", 0) != 1: + return False + if getattr(self, "_vc_session_started", 0) != 1: + return False + except Exception: + return False + try: + self._server_vad_silence = 0 + self._vc_defer_vad_uplink_stop = 0 + self._vc_vad_had_active_after_silence = 0 + self.Close_flag = 0 + self._vc_clear_stale_record_state("asr.empty/reopen") + self._long_dialogue_publish_listening("asr.empty/reopen") + self.request_uplink_start("asr.empty/reopen") + print("[VC][ASR] long empty hint done -> reopen uplink") + return True + except Exception as e: + usys.print_exception(e) + return False + def _handle_pwk_short_release(self, event=None, msg=None, merged_ai_tail=False): """电源键短按:读留言/会议;否则按 UX 表 cancel+Close(清 sid)。""" if self._vc_ms_keys_blocked("pwk_release"): @@ -867,6 +997,13 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): except Exception: return 0 + def _vc_persist_vc_mode(self): + """关机/模式切换:把当前对话模式写入存储。""" + try: + EventMesh.publish("set_storage_config", ["VC_mode", int(self.VC_mode)]) + except Exception: + pass + def _ptt_should_hold_listening_led(self): """单对话打断/cancel 等待/录音:保持聆听蓝快闪,勿经 fsm 回到 playing/thinking。""" try: @@ -1334,7 +1471,12 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): except Exception: pass def battery_priority_mute_vc(self, event=None, msg=None): - """低电/关机提示音:短暂停 VC TTS,避免被流式播放挡住。""" + """低电/关机提示音:停 VC TTS 下行并关会话,避免流式 TTS 抢播本地提示音。""" + try: + self.VC_stop_play_audio_flag = 0 + self._drop_tts_audio = 1 + except Exception: + pass try: self._ptt_hard_mute_local_playback() except Exception: @@ -1344,6 +1486,11 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): self.VC_Play_End() except Exception: pass + try: + if getattr(self, "VC_satrt_flag", 0) == 1: + EventMesh.publish("publish_AI_btnInfo", {"func": self.Close}) + except Exception: + pass def _vc_turn_current(self): try: return int(getattr(self, "_vc_turn_gen", 0)) @@ -1840,12 +1987,18 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): self.is_auth = 1 #是否开启dmp鉴权 #self.VC_mode = 1 #0:短按连续问答模式 1:长按录音模式 self.VC_mode = EventMesh.publish("get_storage_config","VC_mode")# + _vc_mode_default = 0 + try: + if "vc_config" in globals() and vc_config: + _vc_mode_default = int(vc_config.get_int("VC_MODE_DEFAULT", 0)) + except Exception: + pass if self.VC_mode == None: - self.VC_mode = 0 + self.VC_mode = _vc_mode_default try: self.VC_mode = int(self.VC_mode) except Exception: - self.VC_mode = 0 + self.VC_mode = _vc_mode_default self.is_up_error= 0 #是否上传错误id self.Close_flag =0 #=1时,连续对话播放完音频就退出 # 叠加态 / 模式切换(vc_overlay,兼容 _vc_ms_phase) @@ -1876,11 +2029,13 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): self._turn_has_asr_completed = 0 self._turn_has_vad_silence = 0 self._turn_has_tts_started = 0 + self._vc_reopen_uplink_after_empty_hint = 0 # VC 会话是否已进入 started(服务端 session initialized) # 重要:在收到 started 前发送音频帧会触发服务端 "session not initialized" → failed → 端侧重连死循环 self._vc_session_started = 0 # 开机/提示音:本轮 started 不自动开麦(避免问候 TTS 前误进 listening) self._skip_started_uplink_once = 0 + self._vc_boot_standby = 0 self._last_tts_kind = "" self._pending_tts_kind = "" # Push-To-Talk(VAD关闭/单对话)是否已发送 audio.create @@ -2338,6 +2493,8 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): self._pending_tts_kind = "boot_prompt" self._last_tts_kind = "boot_prompt" self._skip_started_uplink_once = 1 + self._vc_boot_standby = 1 + self.Close_flag = 1 except Exception: pass EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start}) @@ -2634,7 +2791,6 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): # EventMesh.publish("publish_AI_btnInfo",{"func":self.Close}) # EventMesh.publish("publish_AI_btnInfo",{"func":utime.sleep_ms,'data':(10)}) self._uplink_request_stop("BT_AI_key_press/compat2") - self._vc_arm_record_start_tone() self._uplink_request_start("BT_AI_key_press/compat2") self.AI_VC_start() @@ -2808,7 +2964,7 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): self._vc_ms_pending_tts_str = tts_str except Exception: pass - EventMesh.publish("set_storage_config", ["VC_mode", self.VC_mode]) + self._vc_persist_vc_mode() try: self._vc_mode_strategy = strategy_for_mode(self.VC_mode) self._vc_mode_strategy_mode = int(self.VC_mode) @@ -3088,9 +3244,12 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): self.VC_satrt_kws_flag = 1 if self.VC_Thinking_timerout < 100: self.VC_Thinking_timerout = 0 - # 长对话:按键唤醒建链时先蓝慢闪聆听;单对话仍只在真开录时切灯 + # 长对话:用户按键唤醒建链时先蓝慢闪;开机问候(_vc_boot_standby)保持 idle try: - if getattr(self, "VC_mode", -1) == 0: + if ( + getattr(self, "VC_mode", -1) == 0 + and not getattr(self, "_vc_boot_standby", 0) + ): self._long_dialogue_publish_listening("AI_VC_start") except Exception: pass @@ -3242,6 +3401,10 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): def Close_VC(self,event,msg): EventMesh.publish("publish_AI_btnInfo",{"func":self.Close}) def Close(self): + try: + self._vc_persist_vc_mode() + except Exception: + pass try: ms_phase = int(getattr(self, "_vc_ms_phase", 0)) if ms_phase in (1, 2, 3) and getattr(self, "_vc_close_reason", "") != "mode_switch_play_end": @@ -3304,6 +3467,10 @@ class AI_VC(VCSessionIoMixin, VCSessionMediaMixin, Abstract): self._skip_started_uplink_once = 0 except Exception: pass + try: + self._vc_boot_standby = 0 + except Exception: + pass try: self._vc_reset_dialogue_mode_state() except Exception: diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session_io.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session_io.py index c53e180b..8585aa21 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session_io.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session_io.py @@ -701,10 +701,9 @@ class VCSessionIoMixin: pass elif not self._vc_effective_asr_text(): try: - print("[VC][ASR] completed empty, skip think tone") - except Exception: - pass - # 空 ASR 不自动 reopen:下一轮由按键或 completed/打断 统一开麦,避免环境声 VAD 循环 + self._vc_handle_asr_empty("asr.completed") + except Exception as e: + usys.print_exception(e) else: stream_on = False try: @@ -1226,7 +1225,7 @@ class VCSessionIoMixin: self.AI_TTS_str = vc_config.get_attr("CMD_TOGGLE_MODE_TO_LONG_TTS", "已切换到长对话模式") except Exception: self.AI_TTS_str = "已切换到长对话模式" - EventMesh.publish("set_storage_config", ["VC_mode", self.VC_mode]) + self._vc_persist_vc_mode() return 0 if it == "volume_set": try: diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session_media.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session_media.py index 9c126e79..adba4f79 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session_media.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/vc_session_media.py @@ -184,9 +184,12 @@ class VCSessionMediaMixin: _vc_play_ai_key_record_start_tone = _vc_play_record_start_tone def _vc_uplink_reason_is_user_key(self, reason): + """按键/PTT 开录(非 server.started、play_end、asr.empty 等自动开麦)。""" r = str(reason or "") if r.startswith("key.press") or r.startswith("BT_AI_key_press"): return True + if r.startswith("ptt_begin") or r == "asr.started/defer": + return True if r == "canceled" and ( getattr(self, "_vc_pending_interrupt_uplink", 0) == 1 or getattr(self, "is_ruppt_tts", 0) == 1 @@ -194,6 +197,18 @@ class VCSessionMediaMixin: return True return False + def _vc_should_play_record_start_tone(self, reason): + """按键开录播 start.mp3;idle 按 AI 建链后 server.started 首开麦也算按键开录。""" + if self._vc_uplink_reason_is_user_key(reason): + return True + r = str(reason or "") + if ( + r.startswith("server.started") + and getattr(self, "_long_dialogue_key_arm", 0) == 1 + ): + return True + return False + def _vc_on_server_record_uplink_ready(self, via): """WS started / asr.started:用户开录走 _vc_user_record_entry,此处仅保留兼容。""" if str(via or "") != "asr.started": @@ -258,7 +273,7 @@ class VCSessionMediaMixin: pass def _vc_user_record_entry(self, reason=""): - """用户开录统一入口:长对话与 PTT 分流(提示音均为 start.mp3)。""" + """开录统一入口;start.mp3 仅按键/PTT 开录时播。""" if getattr(self, "VC_mode", -1) == 1: self._vc_user_record_entry_ptt(reason) else: @@ -266,10 +281,9 @@ class VCSessionMediaMixin: def _vc_user_record_entry_long(self, reason=""): """ - 长对话打断/续聊: - 1) VC_Speech_Start 仅缓冲(record_state=1 不上传) - 2) 播 start.mp3 - 3) 提示音结束后再 VC_Speech_Start_now + 蓝慢闪 + 长对话开麦: + - 按键/打断续聊:先 start.mp3,滴声结束后再上行+蓝慢闪 + - 自动续聊(server.started/play_end 等):不播 start,直接上行 """ try: self._vc_user_record_open_reason = str(reason or "") @@ -292,7 +306,8 @@ class VCSessionMediaMixin: pass played = False try: - played = self._vc_play_record_start_tone(via=reason) + if self._vc_should_play_record_start_tone(reason): + played = self._vc_play_record_start_tone(via=reason) except Exception: played = False if not played: @@ -307,7 +322,7 @@ class VCSessionMediaMixin: total_ms = 200 self._vc_user_record_tone_timer.stop() self._vc_user_record_tone_timer.start(total_ms, 0, self._vc_user_record_tone_timer_cb) - print("[VC][user_record] entry_long reason={} tone_ms={}".format(reason, total_ms)) + print("[VC][user_record] entry_long key_tone reason={} tone_ms={}".format(reason, total_ms)) except Exception as e: usys.print_exception(e) try: @@ -317,7 +332,7 @@ class VCSessionMediaMixin: def _vc_user_record_entry_ptt(self, reason=""): """ - 单对话 PTT 长按:立即录音+上行;并行播 start.mp3;松手 end_speech 停传。 + 单对话 PTT 长按:立即录音+上行;按键开录时并行播 start.mp3;松手 end_speech 停传。 """ try: self._vc_user_record_open_reason = str(reason or "") @@ -350,7 +365,8 @@ class VCSessionMediaMixin: except Exception: pass try: - self._vc_play_record_start_tone(via=reason) + if self._vc_should_play_record_start_tone(reason): + self._vc_play_record_start_tone(via=reason) except Exception: pass try: @@ -367,12 +383,12 @@ class VCSessionMediaMixin: self._vc_reset_long_idle_timer(reason) except Exception: pass + self._vc_user_record_entry(reason) try: if getattr(self, "VC_mode", 0) == 0: self._long_dialogue_key_arm = 0 except Exception: pass - self._vc_user_record_entry(reason) def _vc_orchestrator_play_end_cb(self, tag=""): """btn 编排线程:TTS 播完统一收尾。""" @@ -1567,6 +1583,10 @@ class VCSessionMediaMixin: self._vc_led_sync_from_fsm() except Exception: pass + try: + self._vc_long_reopen_after_asr_empty_hint() + except Exception: + pass try: self._vc_notify_queue_flush() except Exception: