新增语音翻译长按上传判断
authorazao <821478748@qq.com>
Tue, 28 Oct 2025 06:42:02 +0000 (14:42 +0800)
committerazao <821478748@qq.com>
Tue, 28 Oct 2025 06:42:02 +0000 (14:42 +0800)
以及会议创建和结束时向iot下发json
AI翻译进入时下发

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 a6b025d..0ad3f43 100644 (file)
@@ -1509,7 +1509,6 @@ class AI_dev(Abstract):
         # if self.KeySOS_timer_flag == 0:
         #     self.KeySOS_timer_flag = 1
         #     self.KeySOS_timer.start(5000, 0, self.KeySos_timer_cb)
-        
         EventMesh.publish("AI_key_release")
         
     def pwk_key_Long_Press(self,event=None,msg=None):
@@ -3160,6 +3159,7 @@ class AI_VC(Abstract):
     
     def come_meet_mode(self, event=None, msg = None):
         if self.meet_flag == 0: #还是为0就提示进入语音留言模式
+            EventMesh.publish("send_meet_open_flag_to_iot")#创建会议
             self.meet_flag=1
             exit_tts ="开启会议纪要,正在录音"
             EventMesh.publish("play_tts",[exit_tts,1])
@@ -3168,6 +3168,7 @@ class AI_VC(Abstract):
         pass
     def exit_meet_mode(self, event=None, msg = None):
         if self.meet_flag == 1: #还是为1就提示已退出会议纪要模式
+            EventMesh.publish("send_meet_end_flag_to_iot")#结束会议
             self.meet_flag=0
             EventMesh.publish("stop_voice_record") #关闭语音录音
             exit_tts ="已退出会议纪要模式"
@@ -3215,9 +3216,6 @@ class AI_VC(Abstract):
             EventMesh.publish("start_voice_record",3)#开始会议录音
             return
         elif self.trans_flag == 1:#AI翻译模式
-            self.Close()
-            EventMesh.publish("open_led_green")
-            EventMesh.publish("start_voice_record",4)#开始翻译录音
             return
         
         EventMesh.publish("stop_voice_record") #关闭语音录音
@@ -3345,6 +3343,9 @@ class AI_VC(Abstract):
     def AI_key_release(self, event=None, msg=None):#按键弹起
         print("AI_key_release123")
         self.key_state = 0
+        if self.trans_flag == 1:#AI翻译模式
+            EventMesh.publish("stop_voice_record") #关闭语音录音
+            return
         if self.voice_flag == 1:
             self.stop_voice_timer.stop()
             self.voice_flag=0
@@ -3384,10 +3385,16 @@ class AI_VC(Abstract):
         if dev_type == 'jswm' or dev_type == 'jswm_BOX'  :
             self.Close()
         else:
+            if self.trans_flag == 1:#AI翻译模式
+                self.Close()
+                EventMesh.publish("open_led_green")
+                EventMesh.publish("start_voice_record",4)#开始翻译录音
             self.AI_key_long_press_flag = 1
 
     def pwk_key_release(self, event, msg):#电源键短按,关闭
         print("pwk_key_release")
+        # EventMesh.publish("set_temp")
+        # return
         EventMesh.publish("exit_meet_mode")#退出会议纪要
         EventMesh.publish("exit_trans_mode")#退出AI翻译
         EventMesh.publish("publish_AI_btnInfo",{"func":self.Close}) 
index f854cc0..0b109ea 100644 (file)
@@ -1311,6 +1311,8 @@ class SockMangager(Abstract):
         self.locate_duration = 0
         self.locate_duration_state = 0
         self.location_info = EventMesh.publish("get_storage_config","locate_duration_time") #获取定位频率信息
+
+        self.temp = 0
         if self.location_info == None:
             self.location_info = {}
         else:
@@ -1334,6 +1336,7 @@ class SockMangager(Abstract):
         EventMesh.subscribe("get_curr_battery_level",self.get_curr_battery_level)
         EventMesh.subscribe("screen_get_battery",self.get_battery)
         EventMesh.subscribe("CHANNEL_IOT_WEB_SEND",self.user_send)
+        EventMesh.subscribe("set_temp",self.set_temp)
         EventMesh.subscribe("GET_IOT_PROTOCOL_CILENT",self.get_iot_protoclo_client)
         EventMesh.subscribe("SEND_JINMOAUDIO_TO_IOT",self.send_jm_audio_to_iot)
         EventMesh.subscribe("SEND_YUYINAUDIO_TO_IOT",self.send_yuyin_audio_to_iot)
@@ -1343,6 +1346,12 @@ class SockMangager(Abstract):
         EventMesh.subscribe("close_websocket_timer",self.close_websocket_timer)
         EventMesh.subscribe("connect_iot_websocket_cb",self.connect_iot_websocket_cb)
         EventMesh.subscribe("set_play_new_voice_list",self.set_play_new_voice_list)
+
+        EventMesh.subscribe("send_meet_open_flag_to_iot",self.send_meet_open_flag_to_iot)#会议创建
+        EventMesh.subscribe("send_meet_end_flag_to_iot",self.send_meet_end_flag_to_iot)#会议结束
+
+        EventMesh.subscribe("send_trans_come_flag_to_iot",self.send_trans_come_flag_to_iot)#进入翻译
+        EventMesh.subscribe("send_trans_ok_flag_to_iot",self.send_trans_ok_flag_to_iot)#向APP发送进入翻译成功
         # import EventMesh
         # EventMesh.publish("play_new_voice_list")
         EventMesh.subscribe("play_new_voice_list",self.play_new_voice_list) #播放语音未读信息
@@ -1612,6 +1621,54 @@ class SockMangager(Abstract):
             usys.print_exception(e)
         pass
     
+    def send_meet_open_flag_to_iot(self,event,msg): #创建会议纪要上报到IOT平台
+        time_tmp = utime.mktime(date_tmp)
+        meet_open = {
+                "msg": "开始会议",
+                "data": None,
+                "cmd": "meet_begin",
+                "ts": time_tmp
+            }
+        send_data = protocol_send_total_data(meet_open)
+        EventMesh.publish("CHANNEL_IOT_WEB_SEND",send_data)
+        pass
+
+    def send_meet_end_flag_to_iot(self,event,msg): #结束会议纪要上报到IOT平台
+        time_tmp = utime.mktime(date_tmp)
+        meet_end = {
+                "msg": "结束会议",
+                "data": None,
+                "cmd": "meet_end",
+                "ts": time_tmp
+            }
+        send_data = protocol_send_total_data(meet_end)
+        EventMesh.publish("CHANNEL_IOT_WEB_SEND",send_data)
+        pass
+
+    def send_trans_come_flag_to_iot(self,event,msg): #进入翻译上报到IOT平台
+        time_tmp = utime.mktime(date_tmp)
+        trans_open = {
+            "msg": "进入翻译模式",
+            "data": None,
+            "cmd": "translate_device_enter",
+            "ts": time_tmp
+        }
+        send_data = protocol_send_total_data(trans_open)
+        EventMesh.publish("CHANNEL_IOT_WEB_SEND",send_data)
+        pass
+
+    def send_trans_ok_flag_to_iot(self,event,msg): #成功进入翻译发给APP
+        time_tmp = utime.mktime(date_tmp)
+        trans_ok = {
+            "msg": "进入成功",
+            "data": None,
+            "cmd": "translate_device_complete",
+            "ts": time_tmp
+        }
+        send_data = protocol_send_total_data(trans_ok)
+        EventMesh.publish("CHANNEL_IOT_WEB_SEND",send_data)
+        pass
+
     def send_jm_audio_to_iot(self,event,msg): #静默录音音频数据上报到IOT平台
         send_data = b''
         send_data = protocol_audio_ji_playload_data(msg[0],msg[1],msg[2])
@@ -1882,13 +1939,20 @@ class SockMangager(Abstract):
     
     def get_iot_protoclo_client(self,event,msg):
         return self.iot_protocol_client
+    def set_temp(self,event,data):
+        if self.temp == 0:
+            self.temp = 1
+        else:
+            self.temp = 0
     def user_send(self,event,data):
         # EventMesh.debug_log("TCP:send data:{}".format(msg))
         # EventMesh.debug_log("TCP:send data:{}".format(msg))
-        sim_state = sim.getStatus() 
+        # sim_state = sim.getStatus() 
         if sim.getStatus() != 1:#网络不正常
             print("无 sim卡")
             return
+        # if self.temp == 1:
+        #     print("没信号")
         else :
             try:
                 if self.start_voice_flag == 0: #如果关闭了就需要重新再
@@ -2603,6 +2667,7 @@ class IOTWeb_play_MusicProtoCol(ProtoCol):
         print("提取到的音乐名称为{},路径为{}".format(musicName,musicUrl))
         EventMesh.publish("play_music",[musicName,musicUrl,1])
         print("recv push_music{}".format(msg))
+
 #音量下发
 class IOTWeb_volumeProtoCol(ProtoCol):
     """volume"""