From: azao <821478748@qq.com> Date: Mon, 15 Dec 2025 09:54:52 +0000 (+0800) Subject: 添加dmp配置以及语速配置 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=761089bd35ede795a7ca93478349ac1b390e993c;p=mirrors%2FASR1603_G5.git 添加dmp配置以及语速配置 修改闹钟无名称报错 修改聆听间隔配置 更改NLP查询指令中断对话为继续对话 --- diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py index 4ed9d309..6173c45f 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py @@ -2489,7 +2489,7 @@ class AI_VC(Abstract): # import voiceCall # voiceCall.callStart("10086") # return - self.http_get_config_flag = 0 + self.http_get_config_flag = 1 if self.http_get_config_flag == 1: try: self.http_get_config()#获取/更新配置参数 @@ -2530,6 +2530,7 @@ class AI_VC(Abstract): EventMesh.subscribe("kws_even",self.kws_even) EventMesh.subscribe("change_volume",self.change_volume) EventMesh.subscribe("find_cmd",self.find_cmd) #查询命令 + EventMesh.subscribe("NLP_set_vad_silence",self.NLP_set_vad_silence) #设置聆听间隔 EventMesh.subscribe("change_voice",self.change_voice) #改变音色 EventMesh.subscribe("Close_VC",self.Close_VC) #外部结束对话 EventMesh.subscribe("get_recv_voice",self.get_recv_voice) #获取留言播放状态 @@ -2639,7 +2640,6 @@ class AI_VC(Abstract): self.power_on_tone = "欢迎使用助手小福" else: self.power_on_tone = "您好!我是世界首创柒牌男装AI生活好帮手-bot_name, 很高兴为您服务,我可以帮您解答柒牌公司知识库、日常生活与工作、旅游信息、健康与运动咨询、教育与学习、情感交流、全球资讯、世界文化等问题!请问您有什么需要我帮忙的吗?" - self.VC_record_TYPE = VC_record_TYPE_PCM #0:PCM 1:AMR self.VC_play_TYPE = VC_play_TYPE_PCM #0:PCM 1:mp3 @@ -2664,7 +2664,7 @@ class AI_VC(Abstract): self.vad_silence = EventMesh.publish("get_storage_config","vad_silence")#语速配置 if self.vad_silence == None: if dev_type == "7PIN" or dev_type == "7PIN_1_5" or dev_type == "7PIN_coze": - self.vad_silence = 200 + self.vad_silence = 1000 else: self.vad_silence = 300 @@ -3180,6 +3180,10 @@ class AI_VC(Abstract): if "inbound_attributess_provider" in data["data"]: self.inbound_attributess_provider = data["data"]["inbound_attributess_provider"] EventMesh.publish("set_storage_config",["inbound_attributess_provider",self.inbound_attributess_provider]) + if "speech_rate" in data["data"]: + self.speech_rate = int(data["data"]["speech_rate"]) + EventMesh.publish("set_storage_config",["speech_rate",self.speech_rate]) + print("配置speech_rate成功") except Exception as e: usys.print_exception(e) else: @@ -5031,29 +5035,29 @@ class AI_VC(Abstract): # self.AI_TTS_str = "明白,语速已经调慢了,当前语速是{}".format(self.speech_rate) # return 0 - if len(text)<22 and(text.find("聆听") != -1 or text.find("明天")!= -1) : - #print("text len :{}".format(len(text))) - if text.find("å¿«") != -1 and text.find("太") == -1 : - self.vad_silence -= 200 - if self.vad_silence < 100: - - self.AI_TTS_str = "已经是最快了" - self.vad_silence = 100 - else: - self.AI_TTS_str = "配置成功,当前语音断句速度是{}毫秒".format(self.vad_silence) - EventMesh.publish("set_storage_config",["vad_silence",self.vad_silence]) - return 0 - if text.find("慢") != -1 and text.find("太") == -1 : - self.vad_silence += 200 - if self.vad_silence > 2000: - self.vad_silence = 2000 - #EventMesh.publish("audio_montage_play",["yinliangyizuixiao.mp3"]) - #self.aud.play(1,0,'U:/static/yinliangyizuixiao.mp3')#音量已最小 - self.AI_TTS_str = "已经是最慢了" - else: - self.AI_TTS_str = "配置成功,当前语音断句速度是{}毫秒".format(self.vad_silence) - EventMesh.publish("set_storage_config",["vad_silence",self.vad_silence]) - return 0 + # if len(text)<22 and(text.find("聆听") != -1 or text.find("明天")!= -1) : + # #print("text len :{}".format(len(text))) + # if text.find("å¿«") != -1 and text.find("太") == -1 : + # self.vad_silence -= 200 + # if self.vad_silence < 100: + + # self.AI_TTS_str = "已经是最快了" + # self.vad_silence = 100 + # else: + # self.AI_TTS_str = "配置成功,当前语音断句速度是{}毫秒".format(self.vad_silence) + # EventMesh.publish("set_storage_config",["vad_silence",self.vad_silence]) + # return 0 + # if text.find("慢") != -1 and text.find("太") == -1 : + # self.vad_silence += 200 + # if self.vad_silence > 2000: + # self.vad_silence = 2000 + # #EventMesh.publish("audio_montage_play",["yinliangyizuixiao.mp3"]) + # #self.aud.play(1,0,'U:/static/yinliangyizuixiao.mp3')#音量已最小 + # self.AI_TTS_str = "已经是最慢了" + # else: + # self.AI_TTS_str = "配置成功,当前语音断句速度是{}毫秒".format(self.vad_silence) + # EventMesh.publish("set_storage_config",["vad_silence",self.vad_silence]) + # return 0 if text.find("升级") != -1 and (text.find("OTA") != -1 or text.find("ota") != -1): if self.ai_OTA.min_sys_ota()==1: self.AI_TTS_str = "有新版本,准备开始升级,升级过程会多次重启设备,请保证流量充足及电量充足" @@ -5696,19 +5700,38 @@ class AI_VC(Abstract): EventMesh.publish("post_device_state") EventMesh.publish("adjust_volume_toBle",self.VC_TTS_volume) self.AI_TTS_str = "好嘞,音量已经调节了,当前音量是{}".format(self.VC_TTS_volume) - + #调节聆听快慢(以秒为单位) + def NLP_set_vad_silence(self,event,msg): + if msg == 1:#聆听变快 + self.vad_silence -= 1000 + if self.vad_silence < 1000: + AI_TTS_str = "已经是最快了" + self.vad_silence = 1000 + else: + AI_TTS_str = "配置成功,当前语音断句速度是{}秒".format(self.vad_silence/1000) + elif msg == 0:#聆听变慢 + self.vad_silence += 1000 + if self.vad_silence > 4000: + self.vad_silence = 4000 + #EventMesh.publish("audio_montage_play",["yinliangyizuixiao.mp3"]) + #self.aud.play(1,0,'U:/static/yinliangyizuixiao.mp3')#音量已最小 + AI_TTS_str = "已经是最慢了" + else: + AI_TTS_str = "配置成功,当前语音断句速度是{}秒".format(self.vad_silence/1000) + EventMesh.publish("set_storage_config",["vad_silence",self.vad_silence]) + return AI_TTS_str #查询指令判断 def find_cmd(self,event ,msg): if "电量" in msg: battery = EventMesh.publish("get_battery") print("电量查询:{}".format(battery)) tts_play_str = "电量剩余百分之{}".format(battery) - EventMesh.publish("play_tts",[tts_play_str,1]) + EventMesh.publish("play_tts",[tts_play_str,0]) # print("电量!!!!!!!!!!!") elif "信号" in msg: signal = net.csqQueryPoll() tts_play_str = "当前信号{}".format(signal) - EventMesh.publish("play_tts",[tts_play_str,1]) + EventMesh.publish("play_tts",[tts_play_str,0]) # print("信号!!!!!!!!!!!") elif "卡号" in msg: # print("卡号!!!!!!!!!!!") @@ -5719,7 +5742,7 @@ class AI_VC(Abstract): tts_play_str = "当前卡号为:{}".format(iccid) else: tts_play_str = "卡号查询失败" - EventMesh.publish("play_tts",[tts_play_str,1]) + EventMesh.publish("play_tts",[tts_play_str,0]) elif "设备号" in msg: imei = modem.getDevImei() if imei != -1 and len(imei) > 5: @@ -5727,10 +5750,10 @@ class AI_VC(Abstract): tts_play_str = "当前设备号为:{}".format(imei) else: tts_play_str = "设备号查询失败" - EventMesh.publish("play_tts",[tts_play_str,1]) + EventMesh.publish("play_tts",[tts_play_str,0]) elif "音量" in msg : tts_play_str = "当前音量是{}".format(self.VC_TTS_volume) - EventMesh.publish("play_tts",[tts_play_str,1]) + EventMesh.publish("play_tts",[tts_play_str,0]) #改变音色判断 def change_voice(self,event ,msg): diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_alarm.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_alarm.py index bdde6c9f..88762c4f 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_alarm.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_alarm.py @@ -787,10 +787,10 @@ class AI_alarm(Abstract): if len(self.alarm_array) > 0: for _alarm in self.alarm_array: alarm_info = {} - if len(_alarm["name"]) == 0: - _alarm["name"] = "闹钟" + # if len(_alarm["name"]) == 0: + # _alarm["name"] = "闹钟" - alarm_info["name"] = _alarm["name"] + # alarm_info["name"] = _alarm["name"] alarm_info["loop"] = _alarm["loop"] alarm_info["state"] = _alarm["state"] alarm_info["time"] = _alarm["time"] diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/protocol.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/protocol.py index 1a49f215..5241a755 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/protocol.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/protocol.py @@ -2725,6 +2725,12 @@ def ai_cmd_handle(cmd): else: tts_play_str = "这个不支持哦,请换一个" EventMesh.publish("play_tts",[tts_play_str,0]) + elif "聆听" in cmd:#聆听快/慢一些 + if "å¿«" in cmd: + tts_play_str = EventMesh.publish("NLP_set_vad_silence",1) + elif "慢" in cmd: + tts_play_str = EventMesh.publish("NLP_set_vad_silence",0) + EventMesh.publish("play_tts",[tts_play_str,0]) elif "这个不支持哦,请换一个" in cmd: tts_play_str = "这个不支持哦,请换一个" EventMesh.publish("play_tts",[tts_play_str,0]) @@ -3572,7 +3578,7 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol): if EventMesh.publish("get_wait_voice_flag") == 0:#未听历史留言 if self.has_processed_history_voice == 0: tts_play_str = "历史未读留言列表为空" - EventMesh.publish("play_tts",[tts_play_str,1]) + EventMesh.publish("play_tts",[tts_play_str,0]) else: self.has_processed_history_voice = 0#读完了置为0 self.history_board_flag = 0#广播置为0