按键音重复播放的问题
authordxy <1731678236qq.com>
Tue, 2 Sep 2025 08:22:48 +0000 (16:22 +0800)
committerdxy <1731678236qq.com>
Tue, 2 Sep 2025 08:22:48 +0000 (16:22 +0800)
侧键打断 按AI键第一次没有按键音的问题

2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py

index 5f78204..1e93caf 100644 (file)
@@ -1274,6 +1274,12 @@ class AI_dev(Abstract):
                 if dev_type == "7PIN_BK"or dev_type == "7PIN_BK_EU"or dev_type == "7PIN_BK_coze":
                     key_count = 3
                 if self.KeyAI_timer_count >= key_count: #防抖200ms
+                    if self.KeySOS_timer_flag == 1:
+                        self.KeySOS_timer_flag = 0
+                        self.KeySos_long_press = 0
+                        self.KeySOS_timer.stop()
+                        print("KeySOS_timer_flag!!!!!!!!!!!!!!!")  #短按两次需要清除标识
+
                     if self.KeyAI_long_press == 0:
                         if self.KeySOS_timer_flag == 0:
                             self.KeySOS_timer_flag = 1
@@ -1306,9 +1312,7 @@ class AI_dev(Abstract):
         if self.KeySos_long_press == 1 and self.KeySOS_timer_flag == 1:
             self.KeySos_long_press=0
             self.KeySOS_timer_flag=0
-            get_sos_flag = EventMesh.publish("get_sos_flag")
-            if get_sos_flag == 0:
-                EventMesh.publish("set_sos_info_call")
+           
         self.KeySos_long_press=0
         self.KeySOS_timer_flag = 0
         return
@@ -2668,6 +2672,7 @@ class AI_VC(Abstract):
         self.tts_in_data_len = 0
         self.tts_out_data_len = 0
         self.VC_satrt_flag = 0
+        self.VC_stop_play_audio_flag = 0
         self.VC_satrt_kws_flag = 0
         self.session_id = ""
         EventMesh.subscribe("AI_key_press", self.AI_key_press)
@@ -2986,7 +2991,8 @@ class AI_VC(Abstract):
         print("pwk_key_release")
         EventMesh.publish("publish_AI_btnInfo",{"func":self.Close}) 
         EventMesh.publish("stop_sos_call")
-        EventMesh.publish("sleep_BT")#休眠蓝牙
+        #EventMesh.publish("sleep_BT")#休眠蓝牙
+
 
     def key_prompt(self):
         EventMesh.publish("audio_montage_play",["key_prompt.mp3"])
@@ -4611,6 +4617,7 @@ class AI_VC(Abstract):
         print("AI_VC_start1")
         EventMesh.publish(constants.EVENT.SYSTEM_UP)#唤醒休眠
         self.VC_satrt_flag = 1
+        self.VC_stop_play_audio_flag = 1
         self.VC_satrt_kws_flag = 1
         if self.VC_Thinking_timerout < 100:
             self.VC_Thinking_timerout = 0
@@ -5045,9 +5052,9 @@ class AI_VC(Abstract):
             print("音频数据还有剩余!!!!!!!!!!!!")
         while True:
             try:
-                if self.AI_audio_queue_thread_lock == 2:
-                        print("AI_audio_queue_thread 该退出了")
-                        break
+                if self.AI_audio_queue_thread_lock == 2 or self.VC_stop_play_audio_flag == 0:
+                    print("AI_audio_queue_thread 该退出了")
+                    break
                 #
                 count+=1
                 if count%500 == 1:
@@ -5134,6 +5141,7 @@ class AI_VC(Abstract):
         EventMesh.publish("audio_montage_play",["xinhaoruo1.mp3"])
 
     def Close(self):
+        self.VC_stop_play_audio_flag = 0
         self.VC_Thinking_timerout = 0
         self.AI_ASR_timer.stop()
         self._1S_timer.stop()