联通了NLP接口以及会议纪要和AI翻译的接口
authorazao <821478748@qq.com>
Mon, 27 Oct 2025 09:16:01 +0000 (17:16 +0800)
committerazao <821478748@qq.com>
Mon, 27 Oct 2025 09:16:01 +0000 (17:16 +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/main_init.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/protocol.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/voice_record.py

index 7083658..a6b025d 100644 (file)
@@ -2531,6 +2531,12 @@ class AI_VC(Abstract):
         self.VC_taskid  = ""
         self.VC_server = 2 #0柒牌正式服务器,1:测试服务器1,2:测试服务器2
         self.voice_flag = 0
+
+        #会议记录标志
+        self.meet_flag = 0
+        #AI翻译标志
+        self.trans_flag = 0
+
         EventMesh.publish("AI_alarm_open")#
         self.server_ip = EventMesh.publish("get_storage_config","server_ip")#
         if self.server_ip == None:
@@ -2908,6 +2914,10 @@ class AI_VC(Abstract):
         EventMesh.subscribe("set_yuyinaudio_flag",self.set_yuyinaudio_flag)
         EventMesh.subscribe("get_yuyinaudio_flag",self.get_yuyinaudio_flag)
         EventMesh.subscribe("exit_voice_message_mode",self.exit_voice_message_mode) #超时未退出语音留言模式
+        EventMesh.subscribe("come_meet_mode",self.come_meet_mode)#进入会议模式
+        EventMesh.subscribe("exit_meet_mode",self.exit_meet_mode)#退出会议模式
+        EventMesh.subscribe("come_trans_mode",self.come_trans_mode)#进入翻译模式
+        EventMesh.subscribe("exit_trans_mode",self.exit_trans_mode)#退出翻译模式
         EventMesh.subscribe("get_audio_play_state",self.get_audio_play_state)
         EventMesh.subscribe("set_voicerupt_flag",self.set_voicerupt_flag)#按键中断触发留言播放
         EventMesh.subscribe("get_recv_voice",self.get_recv_voice)#获取是否收到留言
@@ -3139,10 +3149,45 @@ class AI_VC(Abstract):
 
     def set_yuyinaudio_flag(self, event=None, msg = None):
         self.voice_flag=0
+    #会议
+    def get_meetaudio_flag(self, event=None, msg = None):
+        return self.meet_flag
+    def set_meetaudio_flag(self, event=None, msg = None):
+        self.meet_flag = 0
+
     def get_audio_play_state(self, event=None, msg = None):
         return self.audio_play_state
+    
+    def come_meet_mode(self, event=None, msg = None):
+        if self.meet_flag == 0: #还是为0就提示进入语音留言模式
+            self.meet_flag=1
+            exit_tts ="开启会议纪要,正在录音"
+            EventMesh.publish("play_tts",[exit_tts,1])
+            utime.sleep_ms(4000)
+            EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_key_press})  
+        pass
+    def exit_meet_mode(self, event=None, msg = None):
+        if self.meet_flag == 1: #还是为1就提示已退出会议纪要模式
+            self.meet_flag=0
+            EventMesh.publish("stop_voice_record") #关闭语音录音
+            exit_tts ="已退出会议纪要模式"
+            EventMesh.publish("play_tts",[exit_tts,1])
+        pass
+    def come_trans_mode(self, event=None, msg = None):
+        if self.trans_flag == 0: #还是为0就提示进入AI翻译模式
+            self.trans_flag=1
+            exit_tts ="已进入AI翻译模式"
+            EventMesh.publish("play_tts",[exit_tts,1])
+        pass
+    def exit_trans_mode(self, event=None, msg = None):
+        if self.trans_flag == 1: #还是为1就提示已退出AI翻译模式
+            self.trans_flag=0
+            EventMesh.publish("stop_voice_record") #关闭语音录音
+            exit_tts ="已退出AI翻译模式"
+            EventMesh.publish("play_tts",[exit_tts,1])
+        pass
     def exit_voice_message_mode(self, event=None, msg = None):
-        if self.voice_flag == 1: #还是为1就提示已退出语音留言模式
+        if self.voice_flag == 1: #还是为1就提示已退出会议纪要模式
             self.voice_flag=0
             exit_tts ="已退出语音留言模式"
             EventMesh.publish("play_tts",[exit_tts,1])
@@ -3162,10 +3207,20 @@ class AI_VC(Abstract):
            # EventMesh.publish("stop_AI_record")
             self.Close()
             EventMesh.publish("open_led_green")
-            EventMesh.publish("start_voice_record",2)#开始静默录音
+            EventMesh.publish("start_voice_record",2)#开始语音录音
+            return
+        elif self.meet_flag == 1:#会议纪要模式
+            self.Close()
+            EventMesh.publish("open_led_green")
+            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") #关闭静默录音
+        EventMesh.publish("stop_voice_record") #关闭语音录音
         print("AI_key_press")
         self.get_config_timer_count = 0
         self.key_state = 1
@@ -3333,6 +3388,8 @@ class AI_VC(Abstract):
 
     def pwk_key_release(self, event, msg):#电源键短按,关闭
         print("pwk_key_release")
+        EventMesh.publish("exit_meet_mode")#退出会议纪要
+        EventMesh.publish("exit_trans_mode")#退出AI翻译
         EventMesh.publish("publish_AI_btnInfo",{"func":self.Close}) 
         EventMesh.publish("stop_sos_call")
         #EventMesh.publish("sleep_BT")#休眠蓝牙
@@ -5227,8 +5284,8 @@ class AI_VC(Abstract):
             json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["use_workflow"]=False
             json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]=""
         elif dev_type == "7PIN" or dev_type == "7PIN_1_5" :#柒牌
-            json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]=""#
-            json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]=""
+            json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7550138354483298347"#
+            json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="7549142130376671267"
             #json_data["payload"]["inbound_attributes"]["vad_silence"] = 1000
         elif dev_type == "7PIN_coze":
             json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7550138354483298347"#
index 46b628f..460ac18 100644 (file)
@@ -249,6 +249,7 @@ def main_init():
             pcr.add_support(pro.IOTWeb_unbind_devProtoCol())
             pcr.add_support(pro.IOTWeb_user_unbind_devProtoCol())
             pcr.add_support(pro.IOTWeb_play_MusicProtoCol())
+            pcr.add_support(pro.IOTWeb_Nlp_ConfigProtoCol())
             sm = pro.SockMangager()
 
             sm.add_support_resolver(pcr)
index ea0643d..f854cc0 100644 (file)
@@ -683,6 +683,9 @@ class WEB_CMD_ENUM:
 
     MUSIC_PLAY_R="music_play_R"
     MUSIC_PLAY_S="music_play_S"
+
+    NLP_PLAY_R = "ai_cmd_R"
+    NLP_PLAY_S = "ai_cmd_S"
 class IOTSendCmdManager(Abstract):
     #
     def __init__(self):
@@ -914,6 +917,30 @@ def protocol_yuyin_voice_playload_data(data,msgid,endflag):
     heards_infor = b''
     heards_infor = MAGIC+VERSION+TYPE+MSGID+ENDFLAG+DATA_LEN+data
     return heards_infor
+
+#会议纪要格式
+def protocol_meet_playload_data(data,msgid,endflag):
+    MAGIC =  (0xfffe).to_bytes(2,"big")
+    VERSION = (0x01).to_bytes(1,"big")#"03".encode('utf-8')
+    TYPE = (0x09).to_bytes(1,"big")
+    MSGID = msgid.to_bytes(4,"big")
+    ENDFLAG = endflag.to_bytes(1,"big")
+    DATA_LEN = (len(data)).to_bytes(4,"big")
+    heards_infor = b''
+    heards_infor = MAGIC+VERSION+TYPE+MSGID+ENDFLAG+DATA_LEN+data
+    return heards_infor
+
+#AI翻译格式
+def protocol_trans_playload_data(data,msgid,endflag):
+    MAGIC =  (0xfffe).to_bytes(2,"big")
+    VERSION = (0x01).to_bytes(1,"big")#"03".encode('utf-8')
+    TYPE = (0x0A).to_bytes(1,"big")
+    MSGID = msgid.to_bytes(4,"big")
+    ENDFLAG = endflag.to_bytes(1,"big")
+    DATA_LEN = (len(data)).to_bytes(4,"big")
+    heards_infor = b''
+    heards_infor = MAGIC+VERSION+TYPE+MSGID+ENDFLAG+DATA_LEN+data
+    return heards_infor
 #sos紧急电话class
 class sosInfoCallManager(Abstract): 
     def __init__(self):
@@ -1310,6 +1337,8 @@ class SockMangager(Abstract):
         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)
+        EventMesh.subscribe("SEND_MEETAUDIO_TO_IOT",self.send_meet_audio_to_iot)
+        EventMesh.subscribe("SEND_TRANSAUDIO_TO_IOT",self.send_trans_audio_to_iot)
         EventMesh.subscribe("open_websocket_timer",self.open_websocket_timer)
         EventMesh.subscribe("close_websocket_timer",self.close_websocket_timer)
         EventMesh.subscribe("connect_iot_websocket_cb",self.connect_iot_websocket_cb)
@@ -1596,6 +1625,22 @@ class SockMangager(Abstract):
         # print("yuyin:{}".format(msg[2]))
         EventMesh.publish("CHANNEL_IOT_WEB_SEND",send_data)
         pass
+
+    def send_meet_audio_to_iot(self,event,msg): #上报会议纪要音频数据到IOT平台
+        send_data = b''
+        send_data = protocol_meet_playload_data(msg[0],msg[1],msg[2])
+        # print("yuyin:{}".format(msg[2]))
+        EventMesh.publish("CHANNEL_IOT_WEB_SEND",send_data)
+        pass
+
+    def send_trans_audio_to_iot(self,event,msg): #上报AI翻译音频数据到IOT平台
+        send_data = b''
+        send_data = protocol_trans_playload_data(msg[0],msg[1],msg[2])
+        # print("yuyin:{}".format(msg[2]))
+        EventMesh.publish("CHANNEL_IOT_WEB_SEND",send_data)
+        pass
+    
+
     #获取电池电量
     def get_battery(self, event=None, msg=None):
         """
@@ -2477,6 +2522,8 @@ def ai_cmd_handle(cmd):
             EventMesh.publish("change_volume",1)
         elif volume == "减小":
             EventMesh.publish("change_volume",0)
+        tts_play_str = "音量已经" + volume
+        EventMesh.publish("play_tts",[tts_play_str,0])
     elif "查询" in cmd:#当指令中有查询时,截取查询操作
         voice_start_index = cmd.index("查询") + len("查询")#动态判断截取部分
         find = cmd[:voice_start_index]#查询截取
@@ -2488,6 +2535,10 @@ def ai_cmd_handle(cmd):
             EventMesh.publish("rate_move",1)
         elif "慢" in find:
             EventMesh.publish("rate_move",0)
+    elif "会议纪要" in cmd:#当指令中有会议纪要时,进入会议纪要模式
+        EventMesh.publish("come_meet_mode")#进入会议纪要
+    elif "翻译" in cmd:#当指令中有翻译时,进入AI翻译模式
+        EventMesh.publish("come_trans_mode")#进入AI翻译纪要
 #NLP指令
 class IOTWeb_Nlp_ConfigProtoCol(ProtoCol):
     """ai_cmd"""
index cf51d06..c0a5ddd 100644 (file)
@@ -54,10 +54,10 @@ class VOICE_RECORD(Abstract): #静默录音
         self.record_fd = None
       
     def post_processor_after_instantiation(self):
-        EventMesh.subscribe("start_voice_record", self.start_voice_record)#开始静默录音
-        EventMesh.subscribe("stop_voice_record", self.stop_voice_record)#停止静默录音
-        EventMesh.subscribe("get_voice_record_flag", self.get_voice_record_flag)#停止静默录音
-        EventMesh.subscribe("get_voice_record_mode", self.get_voice_record_mode)#停止静默录音
+        EventMesh.subscribe("start_voice_record", self.start_voice_record)#开始IOT录音
+        EventMesh.subscribe("stop_voice_record", self.stop_voice_record)#停止IOT录音
+        EventMesh.subscribe("get_voice_record_flag", self.get_voice_record_flag)#获取iot录音标志
+        EventMesh.subscribe("get_voice_record_mode", self.get_voice_record_mode)#获取iot录音模式
 
     def get_voice_record_flag(self,event,msg):
         return self.start_voice_record_flag
@@ -82,7 +82,7 @@ class VOICE_RECORD(Abstract): #静默录音
         #开启线程 
         #开启录音
         EventMesh.publish("stop_voice_record")
-        self.voice_mode = msg #录音模式 1静默录音 2 语音留言 0没有录音模式
+        self.voice_mode = msg #录音模式 1静默录音 2 语音留言 3 会议纪要 4 AI翻译 0没有录音模式
         self.start_voice_record_flag = 1
         self.connect_web_count = 0
         if self.voice_record_thread_id == 0:
@@ -203,6 +203,22 @@ class VOICE_RECORD(Abstract): #静默录音
                                 EventMesh.publish("SEND_YUYINAUDIO_TO_IOT",[read_buf,self.msgid_int,0])
                                 break
                             EventMesh.publish("SEND_YUYINAUDIO_TO_IOT",[read_buf,self.msgid_int,self.start_voice_record_flag])
+                        elif self.voice_mode == 3: #会议纪要开始
+                            get_sos_flag = EventMesh.publish("get_sos_flag") 
+                            if get_sos_flag != 0:
+                                print("打电话退出会议纪要")
+                                EventMesh.publish("stop_voice_record")
+                                EventMesh.publish("SEND_MEETAUDIO_TO_IOT",[read_buf,self.msgid_int,0])
+                                break
+                            EventMesh.publish("SEND_MEETAUDIO_TO_IOT",[read_buf,self.msgid_int,self.start_voice_record_flag])
+                        elif self.voice_mode == 4: #会议纪要开始
+                            get_sos_flag = EventMesh.publish("get_sos_flag") 
+                            if get_sos_flag != 0:
+                                print("打电话退出AI翻译")
+                                EventMesh.publish("stop_voice_record")
+                                EventMesh.publish("SEND_TRANSAUDIO_TO_IOT",[read_buf,self.msgid_int,0])
+                                break
+                            EventMesh.publish("SEND_MEETAUDIO_TO_IOT",[read_buf,self.msgid_int,self.start_voice_record_flag])
                         if self.start_voice_record_flag == 0:
                             break
                     except Exception as e: