音色协议
authordxy <1731678236qq.com>
Tue, 19 Aug 2025 11:15:27 +0000 (19:15 +0800)
committerdxy <1731678236qq.com>
Tue, 19 Aug 2025 11:15:27 +0000 (19:15 +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 59f8485..2771b07 100644 (file)
@@ -4767,6 +4767,13 @@ class AI_VC(Abstract):
         self.vad_silence = msg
         EventMesh.publish("set_storage_config",["vad_silence",self.vad_silence])  
         # EventMesh.publish("publish_AI_btnInfo",{"func":self.play_new_voice_cb,"data":msg}) 
+        #设置tts参数
+    def set_VC_TTS_voice_type(self,event = None,msg= None):
+        self.VC_TTS_voice_type["APP_voice"] = msg
+        #self.VC_TTS_voice_type[self.VC_TTS_voice_key]
+        self.VC_TTS_voice_key = "APP_voice"
+        EventMesh.publish("set_storage_config",["VC_TTS_voice_type",self.VC_TTS_voice_type])
+        EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
     def play_new_voice(self,event = None,msg= None):
         EventMesh.publish("publish_AI_btnInfo",{"func":self.play_new_voice_cb,"data":msg}) 
     def play_new_voice_cb(self,data):
index 6d3d19d..498ce2a 100644 (file)
@@ -1048,6 +1048,13 @@ class sosInfoCallManager(Abstract):
         EventMesh.publish("stop_AI_record")
         if self.sos_flag == 0:
             self.sos_flag = 1
+        tts_str = "正在启动sos呼叫中"
+        EventMesh.publish("stop_voice_record") #电话优先级最高
+        EventMesh.publish("stop_AI_record")
+        EventMesh.publish("play_tts",[tts_str,1])  #播放tts闹钟文本内容
+        self.sos_timer1.start(5000, 0, self.call_sos_cb)
+
+    def call_sos_cb(self,*argc):
         sos_flag = self.sos_flag
         EventMesh.debug_log('voicecall sos_flag',sos_flag)
         if sos_flag == 0 :
@@ -1149,7 +1156,7 @@ class sosInfoCallManager(Abstract):
                 EventMesh.debug_log('voicecall disconnect end !!!')
                 self.close_call_timer()
                 self.call_state = 0
-                self.set_sos_info_call(1,1)
+                EventMesh.publish("set_sos_info_call")
                 pass
             self.call_state = 0
                 #再次拨打下一个电话号码
@@ -1220,6 +1227,10 @@ class SockMangager(Abstract):
         self.voice_id = "0"
         self.bt_connect_list = []
         self.new_voice_list = []
+        self.locate_duration_c = 0
+        self.locate_duration_c = EventMesh.publish("get_storage_config","locate_duration_time") #获取定位频率
+        if self.locate_duration_c == None:
+            self.locate_duration_c=0
         EventMesh.subscribe("REPORT_ALARM_TO_IOT",self.report_alarm_to_iot)
 
     def report_alarm_to_iot(self,event,msg):
@@ -1251,6 +1262,7 @@ class SockMangager(Abstract):
         EventMesh.subscribe("get_play_new_voice_state",self.get_play_new_voice_state)
         EventMesh.subscribe("send_bt_connect_state_to_iot",self.send_bt_connect_state_to_iot)
         EventMesh.subscribe("send_unbind_dev_to_iot",self.send_unbind_dev_to_iot)
+        EventMesh.subscribe("set_location_timer",self.set_location_timer)
         # count = 0
         # while True:
         #     count += 1
@@ -1273,6 +1285,8 @@ class SockMangager(Abstract):
         self.new_voice_list = []
         self.connect_web_timer.start(2000,0,self.iot_web_connect_timerCb)
         
+    def set_location_timer(self,event,msg):
+        self.locate_duration_c=msg
 
     def save_bt_connect_list(self,event,msg):
         print("msg:{}".format(msg))
@@ -1521,6 +1535,9 @@ class SockMangager(Abstract):
         bat_total_value = bat_total_value//curr_count#一分钟更新一次电量 10个平均值
         # EventMesh.publish("AI_schedule_open")#读取闹钟数组
         # print("AI_schedule_open!!!")
+        if EventMesh.publish("get_sos_flag") != None:
+            if EventMesh.publish("get_sos_flag") == 1:
+                EventMesh.publish(constants.EVENT.SYSTEM_UP)#唤醒休眠
         EventMesh.publish("AI_alarm_start") #检查是否有闹钟需要提醒
         EventMesh.publish("AI_schedule_open")#检查日程是否需要提醒
         # self.alarm_test()
@@ -1532,13 +1549,13 @@ class SockMangager(Abstract):
             self.reconnect_count = 0
             EventMesh.publish("publish_AI_btnInfo",{"func":self.hr_report_publish_event,"data":0}) 
 
-        locate_duration_c = EventMesh.publish("get_storage_config","locate_duration_time") #获取定位频率
-        if locate_duration_c == None:
+        
+        if self.locate_duration_c == None:
             self.timerLocation = 0
         else:
-            if locate_duration_c != 0:
+            if self.locate_duration_c != 0:
                 self.timerLocation+=DEFINE_TIME_COUNT
-                if self.timerLocation >= locate_duration_c:
+                if self.timerLocation >= self.locate_duration_c:
                     self.timerLocation= 0
                     print("timerLocation")
                     EventMesh.publish(constants.EVENT.START_LOCATION,WEB_CMD_ENUM.POST_LOCATION_S_CMD) #定位上报
@@ -1996,8 +2013,9 @@ class IOTWeb_locatedurationProtoCol(ProtoCol):
         #     "data":300,0表示关
         # }
         if "data" in msg:
-            locate_duration_time = msg["data"]
-            EventMesh.publish("set_storage_config",["locate_duration_time",int(locate_duration_time)])
+            locate_duration_time = int(msg["data"])
+            EventMesh.publish("set_storage_config",["locate_duration_time",locate_duration_time])
+            EventMesh.publish("set_location_timer",locate_duration_time)
             locate_duration_c = EventMesh.publish("get_storage_config","locate_duration_time")
             print("locate_duration_c:{}".format(locate_duration_c))
         
@@ -2740,18 +2758,25 @@ class IOTWeb_chat_configProtoCol(ProtoCol):
         #         "voiceId":"音色ID,火山音色或者科大讯飞音色ID"
         #     }
         # }
-        # {'msg': '.', 'data': {'vadDuration': 600, 'provider': None, '': None, 'speed': '1.0', 'voiceId': ''}, 'ts': 1755593006265, 'cmd': 'chat_config'}
+        # {'msg': '测试聊天配置.', 'data': {'botName': '柒乐乐', 'vadDuration': 600, 'speed': '1.0', 'provider': 'iflytek', 'voiceId': 'x3_linlin'}, 
+        #  'ts': 1755600807553, 'cmd': 'chat_config'}
+
         if "data" in msg:
             data = msg["data"]
             speed = data["speed"]
             vadDuration = data["vadDuration"]
             voiceId = data["voiceId"]
+            provider = data["provider"]
             if speed !=  None:
                 if len(speed) != 0:
                     EventMesh.publish("SET_SPEECH_RATE",speed)
-            if voiceId != None:
-                if len(voiceId) != 0:
-                    EventMesh.publish("set_vad_silence",voiceId)
+            if vadDuration != None:
+                if len(vadDuration) != 0:
+                    EventMesh.publish("set_vad_silence",vadDuration)
+            if provider != None:
+                if len(provider) != 0:
+                    pass
+                    # EventMesh.publish("set_vad_silence",vadDuration)
         EventMesh.publish(WEB_CMD_ENUM.CHAT_CONFIG_S)
 #获取AI对话音色配置
 class IOTWeb_get_chat_configProtoCol(ProtoCol):