修改播放语音列表为正序
authorazao <821478748@qq.com>
Tue, 16 Dec 2025 02:48:22 +0000 (10:48 +0800)
committerazao <821478748@qq.com>
Tue, 16 Dec 2025 13:06:20 +0000 (21:06 +0800)
修改未听留言循环播放的问题
以及在循环留言的情况下历史留言列表无法播放的问题

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

index 6173c45..9836814 100644 (file)
@@ -2518,6 +2518,8 @@ class AI_VC(Abstract):
         self.play_new_voice_flag =0 #播放文字留言flag
 
         self.wait_first_flag = 0#是否进入未读判定(只播报一次)
+        self.wait_first_timer = osTimer()#如果播放未读留言的时候未读则不要播放了
+        self.wait_first_cnt = 0
         EventMesh.subscribe("play_tts",self.play_tts)
         EventMesh.subscribe("play_new_voice",self.play_new_voice)
         EventMesh.subscribe("play_his_voice",self.play_his_voice)
@@ -4319,9 +4321,8 @@ class AI_VC(Abstract):
                                 EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_error,"data":jsload_data["payload"]["message"]}) 
                             pass
                            
-                        elif jsload_data["event"] == "audio.convert.completed":#音频转成完成没有出错 接口
-                            
-                            self.VC_state = VC_State_End
+                        elif jsload_data["event"] == "audio.convert.completed":#音频转成完成没有出错 接口 
+                            # self.VC_state = VC_State_End
                             print("未读留言初始数值:{}".format(self.pwk_cnt_voice))
                             if self.pwk_notice_flag == 1:#只有在播放的时候才会去计数
                                 if self.pwk_cnt_voice > 0:
@@ -4334,6 +4335,7 @@ class AI_VC(Abstract):
                                 self.wait_first_flag = 0#让下次未读播放提示恢复
                                 self.voice_notice = 1#开启回复
                                 EventMesh.publish("set_storage_config",["is_noread_voice",0])
+                                
                             if self.voice_choose_flag == 1:#播放完语音后,有冲突的时候关闭
                                 self.voice_choose_flag = 0
                                 self.Close_flag = 1
@@ -4348,10 +4350,6 @@ class AI_VC(Abstract):
                                 self.voice_flag = 1
                                 print("语音留言回复停止")
                                 self.revoice_timer.start(1000,1,self.revoice_judge)
-                            # if EventMesh.publish("get_play_new_voice_state")== 1:
-                            #     EventMesh.publish("set_play_new_voice_state",0)
-                            #     # EventMesh.publish("update_play_new_voice_info")
-                            #     EventMesh.publish("play_new_voice_list")
                             print("是否未读:{},是否播完:{}".format(EventMesh.publish("get_wait_voice_flag"),len(EventMesh.publish("get_play_new_voice_list"))))
                             # if EventMesh.publish("get_wait_voice_flag") == 1 and len(EventMesh.publish("get_play_new_voice_list")) ==0:#还在未读并且列表为空
                             #     self.wait_first_flag = 0
@@ -5914,6 +5912,7 @@ class AI_VC(Abstract):
             if self.wait_first_flag == 0:
                 tts_play_str = "您有" + str(len(EventMesh.publish("get_play_new_voice_list"))) + "条未读留言,10秒内按下中间键可以收听"
                 EventMesh.publish("play_tts",[tts_play_str,1])  
+                # self.wait_first_timer.start(1000,1,self.noread_wait_vocie)
                 self.wait_first_flag = 1
             if new_voice_url != "":
                 self.recv_voice = 1#收到留言
@@ -5937,6 +5936,18 @@ class AI_VC(Abstract):
         except Exception as e:
                 usys.print_exception(e)   
         pass
+    def noread_wait_vocie(self,*args):#如果一直没读
+        self.wait_first_cnt += 1
+        print("未读留言等待收听中:{}".format(self.wait_first_cnt))
+        if EventMesh.publish("get_recv_voice") == 1:#如果检测到留言播放
+            self.wait_first_cnt = 0
+            self.wait_first_timer.stop()
+        if self.wait_first_cnt == 15:
+            EventMesh.publish("set_wait_first_flag",0)
+            EventMesh.publish("set_history_voice_flag",0)
+            EventMesh.publish("set_wait_voice_flag",0)
+            self.wait_first_cnt = 0
+            self.wait_first_timer.stop()
     #音乐播放
     def play_music(self,event = None,msg= None):
         EventMesh.publish("publish_AI_btnInfo",{"func":self.play_music_cb,"data":msg}) 
index 5241a75..6dfbd83 100644 (file)
@@ -1592,9 +1592,12 @@ class SockMangager(Abstract):
 
     def play_new_voice_list_timer_cb(self):
         print("play_new_voice_list:{}".format(len(self.new_voice_list)))
+        voice_list = self.new_voice_list
         if len(self.new_voice_list) != 0:
             
             for i,data in enumerate(self.new_voice_list):
+                if EventMesh.publish("get_history_voice_flag") == 1:
+                    data = voice_list[len(self.new_voice_list)-1-i]
                 print("data:{}".format(data))
                 self.voice_index = i
                 self.voice_id = str(data["id"])
@@ -3559,7 +3562,6 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
         EventMesh.subscribe("set_open_device",self.set_open_device)
         EventMesh.subscribe("get_open_device",self.get_open_device)
     def send(self, event, msg):
-
         print("send find_voice_msg_list")
 
     def recv(self, event, msg):
@@ -3577,7 +3579,7 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
             if len(voice_list) == 0:#为空
                 if EventMesh.publish("get_wait_voice_flag") == 0:#未听历史留言
                     if self.has_processed_history_voice == 0:
-                        tts_play_str = "å\8e\86å\8f²æ\9cªè¯»ç\95\99è¨\80å\88\97表为空"
+                        tts_play_str = "å·²æ\97 æ\9b´å¤\9aå\8e\86å\8f²ç\95\99è¨\80"
                         EventMesh.publish("play_tts",[tts_play_str,0])
                     else:
                         self.has_processed_history_voice = 0#读完了置为0
@@ -3597,6 +3599,8 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
                     if self.history_board_flag == 0:
                         tts_play_str = "您共有" + str(len(voice_list)) + "条历史留言,正在为您播放"
                         EventMesh.publish("play_tts",[tts_play_str,1])
+                        EventMesh.publish("set_pwk_notice_flag",1)
+                        EventMesh.publish("set_pwk_cnt_voice",len(voice_list))#设置多,防止进入留言播完判断
                         self.history_board_flag = 1
                         self.has_processed_history_voice = 1
                     for da in voice_list:
@@ -3623,7 +3627,7 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
                     EventMesh.publish("set_play_new_voice_list",new_voice_list)
                     EventMesh.publish("play_new_voice_list")
     def set_history_board_flag(self,event,msg):
-        self.history_board_flag = msg           
+        self.history_board_flag = msg             
     def set_open_device(self,event,msg):
         self.open_device = msg
     def get_open_device(self,event,msg):
@@ -3804,7 +3808,7 @@ class IOTWeb_new_voice_msg_listProtoCol(ProtoCol):
             pass
             if self._1M_flag == 0 :
                 print("等待留言60S倒计时开启")
-                self._1M_timer.start(60000, 1, self._1M_timer_cb)
+                self._1M_timer.start(60000, 0, self._1M_timer_cb)
                 self._1M_flag = 1
         EventMesh.publish(WEB_CMD_ENUM.NEW_VOICE_MSG_LIST_S)
         print("recv new_voice_msg_list{}".format(msg))