From: azao <821478748@qq.com> Date: Wed, 31 Dec 2025 10:03:16 +0000 (+0800) Subject: 修改音量修改未设限的问题 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=6997366e97ab9a5c69fffdffb32799c52eed5eff;p=mirrors%2FASR1603_G5.git 修改音量修改未设限的问题 对一代的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 d62b6183..987d0fd1 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 @@ -5742,41 +5742,41 @@ class AI_VC(Abstract): EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) print("VC_TTS_voice_type:{}".format(self.VC_TTS_voice_type)) print("VC_TTS_voice_key:{}".format(self.VC_TTS_voice_key)) - #修改音量大小 msg为1则为加大,msg为0则为减小 + #修改音量大小 msg为1则为加大,msg为0则为减小,返回1成功,返回0失败 def change_volume(self,event =None, msg =None): if msg == 0 : self.VC_TTS_volume -= 10 if self.VC_TTS_volume < 0: self.VC_TTS_volume = 0 - self.AI_TTS_str = "音量已经是最小啦" + return 0 else: self.aud.setVolume(self.VC_TTS_volume //10) EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume]) EventMesh.publish("post_device_state") EventMesh.publish("adjust_volume_toBle",self.VC_TTS_volume) - self.AI_TTS_str = "好嘞,音量已经调小了,当前音量是{}".format(self.VC_TTS_volume) + return 1 elif msg == 1: self.VC_TTS_volume += 10 if self.VC_TTS_volume > 100: self.VC_TTS_volume = 100 - self.AI_TTS_str = "音量已经是最大啦" + return 0 else: self.aud.setVolume(self.VC_TTS_volume //10) EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume]) EventMesh.publish("post_device_state") EventMesh.publish("adjust_volume_toBle",self.VC_TTS_volume) - self.AI_TTS_str = "好嘞,音量已经调大了,当前音量是{}".format(self.VC_TTS_volume) + return 1 elif msg >= 100:#修改为具体音量 if msg > 200: self.VC_TTS_volume = 100 - self.AI_TTS_str = "音量已设为最大" + return 0 else: self.VC_TTS_volume = msg - 100#还原数据 self.aud.setVolume(self.VC_TTS_volume //10) EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume]) EventMesh.publish("post_device_state") EventMesh.publish("adjust_volume_toBle",self.VC_TTS_volume) - self.AI_TTS_str = "好嘞,音量已经调节了,当前音量是{}".format(self.VC_TTS_volume) + return 1 #调节聆听快慢(以秒为单位) def NLP_set_vad_silence(self,event,msg): if msg == 1:#聆听变快 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 0ba3af3b..1291de2b 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 @@ -2686,14 +2686,6 @@ def ai_cmd_handle(cmd): volume = "变慢" tts_play_str = "语速已经" + volume EventMesh.publish("play_tts",[tts_play_str,0]) - elif "会议纪要" in cmd:#当指令中有会议纪要时,进入会议纪要模式 - if dev_type == "7PIN_1_5": - print("cmd:已进入会议") - EventMesh.publish("come_meet_mode")#进入会议纪要 - elif "翻译" in cmd:#当指令中有翻译时,进入AI翻译模式 - if dev_type == "7PIN_1_5": - print("cmd:已进入翻译") - EventMesh.publish("come_trans_mode")#进入AI翻译纪要 elif "声音改为" in cmd:#当指令中有声音改为时,进入音色修改 voice_start_index = cmd.index("声音改为") + len("声音改为")#动态判断截取部分 find = cmd[voice_start_index:]#查询截取 @@ -2707,29 +2699,38 @@ def ai_cmd_handle(cmd): print("find = {}".format(find)) volume = int(find) volume += 100#设置音量以100-200为参数 - EventMesh.publish("change_volume",volume) - tts_play_str = "音量已经改为" + find - EventMesh.publish("play_tts",[tts_play_str,0]) + result = EventMesh.publish("change_volume",volume) + if result == 1: + tts_play_str = "音量已经改为" + find + EventMesh.publish("play_tts",[tts_play_str,0]) + else: + tts_play_str = "设置失败,请重新设置0~100的音量大小" + EventMesh.publish("play_tts",[tts_play_str,0]) if "加大" in cmd: - EventMesh.publish("change_volume",1) - tts_play_str = "音量已经加大" - EventMesh.publish("play_tts",[tts_play_str,0]) + result = EventMesh.publish("change_volume",1) + if result == 1: + tts_play_str = "音量已经加大" + EventMesh.publish("play_tts",[tts_play_str,0]) + else: + tts_play_str = "当前音量已经是最大了" + EventMesh.publish("play_tts",[tts_play_str,0]) elif "减小" in cmd: - EventMesh.publish("change_volume",0) - tts_play_str = "音量已经减小" - EventMesh.publish("play_tts",[tts_play_str,0]) + result = EventMesh.publish("change_volume",0) + if result == 1: + tts_play_str = "音量已经减小" + EventMesh.publish("play_tts",[tts_play_str,0]) + else: + tts_play_str = "当前音量已经是最小了" + EventMesh.publish("play_tts",[tts_play_str,0]) - elif "查看历史留言" in cmd :#当指令中有查看历史留言时,调用历史留言接口 - if dev_type == "7PIN_1_5": - EventMesh.publish(WEB_CMD_ENUM.GET_NEW_VOICE_MSG_S) - EventMesh.publish("set_history_voice_flag",1)#修改标志位 - EventMesh.publish("clean_unread_vocie")#清空未读多条一起下发记录 - EventMesh.publish("set_storage_config",["is_noread_voice",0]) - pass elif "语速倍速设置为:" in cmd:#修改对话模式 voice_start_index = cmd.index("语速倍速设置为:") + len("语速倍速设置为:")#动态判断截取部分 find = cmd[voice_start_index:]#查询截取 print("find = {}".format(find)) + if float(find) > 2.0 or float(find) < 0.5: + tts_play_str = "抱歉,语速仅支持0.5-2倍,请重新设置" + EventMesh.publish("play_tts",[tts_play_str,0]) + return EventMesh.publish("SET_SPEECH_RATE",float(find)) tts_play_str = "语速已经改为" + find EventMesh.publish("play_tts",[tts_play_str,0]) @@ -2744,7 +2745,27 @@ def ai_cmd_handle(cmd): EventMesh.publish("play_tts",[tts_play_str,0]) elif "不支持的操作" in cmd: tts_play_str = "抱歉呀,暂不支持该命令" - EventMesh.publish("play_tts",[tts_play_str,0]) + EventMesh.publish("play_tts",[tts_play_str,0]) + + if dev_type == "7PIN":#一代没有下面的功能 + print("一代不支持") + return + if "会议纪要" in cmd:#当指令中有会议纪要时,进入会议纪要模式 + if dev_type == "7PIN_1_5": + print("cmd:已进入会议") + EventMesh.publish("come_meet_mode")#进入会议纪要 + elif "翻译" in cmd:#当指令中有翻译时,进入AI翻译模式 + if dev_type == "7PIN_1_5": + print("cmd:已进入翻译") + EventMesh.publish("come_trans_mode")#进入AI翻译纪要 + elif "查看历史留言" in cmd :#当指令中有查看历史留言时,调用历史留言接口 + if dev_type == "7PIN_1_5": + EventMesh.publish(WEB_CMD_ENUM.GET_NEW_VOICE_MSG_S) + EventMesh.publish("set_history_voice_flag",1)#修改标志位 + EventMesh.publish("clean_unread_vocie")#清空未读多条一起下发记录 + EventMesh.publish("set_storage_config",["is_noread_voice",0]) + pass + #NLP指令 class IOTWeb_Nlp_ConfigProtoCol(ProtoCol): """ai_cmd"""