From: p15692025051 <846603105@qq.com> Date: Fri, 6 Jun 2025 08:04:25 +0000 (+0800) Subject: 大锤测试前备份 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=a8ce8cc858e4157dfb04e24a62fad7d40762a4c0;p=mirrors%2FASR1603_G5.git 大锤测试前备份 --- diff --git a/2.sdk/project/7PIN/sdk/services/microPython/ports/quectel/core/ai_VC.py b/2.sdk/project/7PIN/sdk/services/microPython/ports/quectel/core/ai_VC.py index 706d0b39..53d5d7a5 100644 --- a/2.sdk/project/7PIN/sdk/services/microPython/ports/quectel/core/ai_VC.py +++ b/2.sdk/project/7PIN/sdk/services/microPython/ports/quectel/core/ai_VC.py @@ -33,14 +33,14 @@ import versions import VAD #dev_type = "G10" #dev_type = "7PIN_BK"#小瑞 -#dev_type = "7PIN_BK_en"#英文小瑞 #dev_type = "7PIN_BK_coze"#k扣子小瑞 -dev_type = "7PIN_BK_EU"#欧美版 -#dev_type = "7PIN"#柒牌 +#dev_type = "7PIN_BK_EU"#英文小瑞 +dev_type = "7PIN"#柒牌 #dev_type = 'momo'#食梦貘 #dev_type = 'sjgq'#四季甘泉 #dev_type = 'szbst'#深圳百事通 #dev_type = 'jswm'#金三完美 +#dev_type = 'jswm_BOX'#金三完美盒子 #dev_type = 'csh'#慈善会 class AI_led(Abstract): def __init__(self): @@ -176,11 +176,30 @@ class AI_led(Abstract): self.led_red.write(0) self.led_blue.write(0) self.led_green.write(0) - +def set_ipv4_datacall(): + # 获取第一路的APN,ipType 等信息 + pdpCtx = dataCall.getPDPContext(1) + if pdpCtx != -1: + if pdpCtx[0] != 0: + # 如果不是用户需要的ipv4,使用如下方式配置,使用如下方式配置 + ret = dataCall.setPDPContext(1, 0,pdpCtx[1],pdpCtx[2],pdpCtx[3],pdpCtx[4]) + if ret == 0: + print('配置成功。') + # cfun0/1后按照配置的信息进行拨号 + net.setModemFun(0) + net.setModemFun(1) + else: + print('配置失败。') + else: + print('已经配置为IPv4') + else: + print('获取PDP Context失败。') audio_buf = ['chenggong', 'didianguanji', 'IMEIhao', 'jianquancuowu', 'key_prompt', 'liuliangtishi', 'Low_power_warning', 'R_CHARGE_FULL', 'R_CHARGE_IN', 'R_CHARGE_OUT', 'R_READ_TIME_0', 'R_READ_TIME_1', 'R_READ_TIME_2', 'R_READ_TIME_3', 'R_READ_TIME_4', 'R_READ_TIME_5', 'R_READ_TIME_6', 'R_READ_TIME_7', 'R_READ_TIME_8', 'R_READ_TIME_9', 'R_READ_TIME_A', 'R_READ_TIME_B', 'R_READ_TIME_C', 'R_READ_TIME_D', 'R_READ_TIME_E', 'R_READ_TIME_F', 'R_READ_TIME_G', 'R_READ_TIME_H', 'R_READ_TIME_I', 'R_READ_TIME_J', 'R_READ_TIME_K', 'R_READ_TIME_L', 'R_READ_TIME_M', 'R_READ_TIME_N', 'R_READ_TIME_O', 'R_READ_TIME_P', 'R_READ_TIME_Q', 'R_READ_TIME_R', 'R_READ_TIME_S', 'R_READ_TIME_T', 'R_READ_TIME_U', 'R_READ_TIME_V', 'R_READ_TIME_W', 'R_READ_TIME_X', 'R_READ_TIME_Y', 'R_READ_TIME_Z', 'send_tone', 'shouhou', 'xinhaoruo1', 'zhengzaiguanji'] class AI_dev(Abstract): # AI def __init__(self): + if(dev_type != "7PIN"): + set_ipv4_datacall() self.is_wdt = 0 #是否开启看门狗 self.VBATT_tab = {"charge_full":4300,"100" :4250 , "90":4179 , "80":4070, "60": 3883, "40":3770, "20":3699, "10":3652,"5":3600,} @@ -205,7 +224,7 @@ class AI_dev(Abstract): print("等待网络 {}...".format(count)) utime.sleep_ms(500) self.KeyAI_timer = osTimer() - if dev_type == "G10": + if dev_type == "G10" : self.extint_AI = ExtInt(ExtInt.GPIO19,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.keyAI_extint_cb) self.pwk_key = ExtInt(ExtInt.GPIO26, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.pwk_extint_cb) elif dev_type == 'jswm': @@ -377,7 +396,7 @@ class AI_dev(Abstract): if self.pwk_key_status == 1:#松开 #print("pwk_key_timer_cb:{}".format(self.pwk_key_timer_count)) key_count = 5 - if dev_type == "7PIN_BK" or dev_type == "7PIN_BK_en"or dev_type == "7PIN_BK_coze": + if dev_type == "7PIN_BK" or dev_type == "7PIN_BK_EU"or dev_type == "7PIN_BK_coze": key_count = 3 if self.pwk_key_timer_count >= key_count: #防抖200ms #EventMesh.publish("AI_key_release") @@ -427,7 +446,7 @@ class AI_dev(Abstract): if self.KeyAI_status == 1:#松开 #print("KeyAI_timer_cb:{}".format(self.KeyAI_timer_count)) key_count = 5 - if dev_type == "7PIN_BK"or dev_type == "7PIN_BK_en"or dev_type == "7PIN_BK_coze": + if dev_type == "7PIN_BK"or dev_type == "7PIN_BK_EU"or dev_type == "7PIN_BK_coze": key_count = 3 if self.KeyAI_timer_count >= key_count: #防抖200ms #EventMesh.publish("AI_key_release") @@ -507,6 +526,8 @@ class AI_dev(Abstract): # if self.Low_power_warning_timer >= 2: # self.Low_power_warning_timer = 0 EventMesh.publish("audio_montage_play",["Low_power_warning.mp3"]) + if self.usb_status == 0 and Vbatt>=self.VBATT_tab["20"]and VC_satrt_flag == 0:#没有充电,电量又正常,关灯 + EventMesh.publish("close_led") if self.usb_status == 0 and Vbatt 50000:#时间错误 + elif data["code"] > 50000:# self.res_error_count+=1 if self.res_error_count>=3: self.res_error_count = 0 - #EventMesh.publish("paly_device_res_error") + + EventMesh.publish("paly_device_res_error") if data["code"] == 50003:#时间错误 self.ntptime_flag = 0 if PASSWORD != None and IV != None: @@ -923,7 +955,11 @@ class device_res_author(Abstract): "nonce":"{}".format(random_string) #随机的16个字符串 } print(ujson.dumps(sign_in_data)) - sign_url = "http://dmp.raisound.com/bz-api/dev/auth/sign_in" #登入地址 + sign_url =None + if dev_type == "7PIN_BK_EU":#英文小瑞 + sign_url = "http://dmp-global.raisound.com/bz-api/dev/auth/sign_in" #登入地址 + else: + sign_url = "http://dmp.raisound.com/bz-api/dev/auth/sign_in" #登入地址 headers_T ={"Content-Type":"application/json"} response_result = 0 response = 0 @@ -982,7 +1018,11 @@ class device_res_author(Abstract): print("no dev_token:{}\r\n".format(token)) #self.dev_sign_in() EventMesh.publish("dev_sign_in") - dev_tokenip = "http://dmp.raisound.com/bz-api/dev/auth/token" #设备新令牌更新地址 + dev_tokenip =None + if dev_type == "7PIN_BK_EU":#英文小瑞 + dev_tokenip = "http://dmp-global.raisound.com/bz-api/dev/auth/token" #设备新令牌更新地址 + else: + dev_tokenip = "http://dmp.raisound.com/bz-api/dev/auth/token" #设备新令牌更新地址 token = self.dev_token if token == None: token = "" @@ -1038,7 +1078,11 @@ class OTA(): sourceVersion = sourceVersion.replace(" ", "0") print("sourceVersion2:{}".format(sourceVersion)) #url = "http://iot.api.thisiot.com/ota/task?deviceId=860132060348836&sourceVersion=2024-12-20-15:35-1" - url = "http://dmp.raisound.com/bz-api/ota/task?deviceId={}&sourceVersion={}".format(modem.getDevImei(),sourceVersion) + url =None + if dev_type == "7PIN_BK_EU":#英文小瑞 + url = "http://dmp-global.raisound.com/bz-api/ota/task?deviceId={}&sourceVersion={}".format(modem.getDevImei(),sourceVersion) + else: + url = "http://dmp.raisound.com/bz-api/ota/task?deviceId={}&sourceVersion={}".format(modem.getDevImei(),sourceVersion) print(url) response = request.get(url,timeout=5) if response.status_code == 200: @@ -1094,7 +1138,11 @@ class OTA(): print("currentVersion1:{}".format(currentVersion)) currentVersion = currentVersion.replace(" ", "0") print("currentVersion2:{}".format(currentVersion)) - url = "http://dmp.raisound.com/bz-api/ota/result?deviceId={}¤tVersion={}".format(modem.getDevImei(),currentVersion) + url =None + if dev_type == "7PIN_BK_EU":#英文小瑞 + url = "http://dmp-global.raisound.com/bz-api/ota/result?deviceId={}¤tVersion={}".format(modem.getDevImei(),currentVersion) + else: + url = "http://dmp.raisound.com/bz-api/ota/result?deviceId={}¤tVersion={}".format(modem.getDevImei(),currentVersion) print(url) response = request.post(url,timeout=5) if response.status_code == 200: @@ -1117,10 +1165,18 @@ class OTA(): if iccid != -1 and len(iccid) > 5: print("pots_ICCID:{}".format(iccid)) #Headers = {'Transfer-Encodong':'chunked'} + token = EventMesh.publish("get_dev_token") + headers_T = None + if token: + headers_T = {"bz-dt":"{}".format(token)} #http://dmp.raisound.com/bz-api/dev/iccid?deviceId=866610001099679&iccid=89860002192307889057 - url = "http://dmp.raisound.com/bz-api/dev/iccid?deviceId={}&iccid={}".format(modem.getDevImei(),iccid) - print(url) - response = request.post(url,timeout=5) + url =None + if dev_type == "7PIN_BK_EU":#英文小瑞 + url = "http://dmp-global.raisound.com/bz-api/dev/iccid?deviceId={}&iccid={}".format(modem.getDevImei(),iccid) + else: + url = "http://dmp.raisound.com/bz-api/dev/iccid?deviceId={}&iccid={}".format(modem.getDevImei(),iccid) + print("{} H:{}".format(url,headers_T)) + response = request.post(url,headers = headers_T,timeout=5) if response.status_code == 200: data = response.json() print("pots_ICCID:{}".format(data)) @@ -1184,7 +1240,7 @@ class AI_VC(Abstract): self.is_VC_ACK = 0 #是否开启ack应答模式 self.is_long_record = 0 #是否开启长录音模式(语音打断模式) self.ai_OTA = OTA() - self.is_auth = 0 #是否开启dmp鉴权 + self.is_auth = 1 #是否开启dmp鉴权 #self.VC_mode = 1 #0:短按连续问答模式 1:长按录音模式 self.VC_mode = EventMesh.publish("get_storage_config","VC_mode")# if self.VC_mode == None : @@ -1218,41 +1274,45 @@ class AI_VC(Abstract): else: #self.server_ip="sevenpin.qipai.com.cn" self.server_ip="118.145.158.207:22082" - if dev_type == 'momo':# - self.server_ip="118.145.158.207:22080" - if dev_type == 'jswm':# - self.server_ip="118.145.158.207:22086" + if dev_type == 'jswm' or dev_type == 'jswm_BOX':# + #self.server_ip="115.190.94.208:22080" + self.server_ip="118.145.158.207:22086" elif dev_type == "7PIN": #self.server_ip="sevenpin.qipai.com.cn" - self.server_ip="118.145.158.207:22082" + # self.server_ip="220.160.104.34" + # self.server_ip="118.145.158.207:22082" + # self.server_ip="118.145.158.207:22080/22087" + self.server_ip="ai.qipai.com" elif dev_type == "G10": self.server_ip="115.190.94.208:22080" elif dev_type == "sjgq": self.server_ip="118.145.158.207:22084" - elif dev_type == "7PIN_BK" or dev_type == 'csh'or dev_type == "7PIN_BK_en"or dev_type == "7PIN_BK_coze": + elif dev_type == "7PIN_BK" or dev_type == 'csh'or dev_type == "7PIN_BK_coze"or dev_type == 'momo': self.server_ip="amp.raisound.com" - self.server_ip="118.145.158.207:22086" - + #self.server_ip="118.145.158.207:22086" + elif dev_type == "7PIN_BK_EU": + #self.server_ip="amp-global.raisound.com" + self.server_ip="amp-cdn-test.raisound.com" #开机提示音 self.power_on_tone = EventMesh.publish("get_storage_config","power_on_tone")# - if dev_type != "7PIN": + if dev_type != "7PIN" and dev_type != "jswm" and dev_type != 'jswm_BOX' and dev_type != "7PIN_BK": self.power_on_tone = None if self.power_on_tone == None: if dev_type == "G10": self.power_on_tone = "已开机,您好!我是北科瑞讯智能 AI bot_name" elif dev_type == "7PIN_BK"or dev_type == "7PIN_BK_coze": - self.power_on_tone = "小瑞来了!我们一起来愉快地聊天吧!" - elif dev_type == "7PIN_BK_en": + self.power_on_tone = "-bot_name来了!我们一起来愉快地聊天吧!" + elif dev_type == "7PIN_BK_EU": self.power_on_tone = "Hi. May I help you ?" - elif dev_type == "momo": + elif dev_type == 'momo': self.power_on_tone = "DuloDulo,我是上古神兽食梦貘,主人可以叫我momo,我来自《山海经》,是一只以梦为食的神秘灵兽,每当颜色朦胧、人们入睡时,我就会悄悄飞到人们的床头,用我长长的鼻子把噩梦统统吞噬掉,只留下甜甜的美梦。从今往后,就由我守护在主人身边,一起度过每一个星河璀璨的夜晚。" elif dev_type == "sjgq": self.power_on_tone = "您好!我是巴马四季甘泉的智能助手。我可以为你解答各种各样的问题,像是有关巴马四季甘泉知识库、中基长寿科学产品、卫斯曼院士国际先进医疗中心的问题,还有日常生活与工作、旅游信息、健康咨询、教育与学习、情感交流、全球资讯、世界文化等方面的问题哦。你有没有这方面的问题想要问我呀?" elif dev_type == "szbst": self.power_on_tone = "深圳百事通来了!请问您有什么需要我帮忙的吗?" - elif dev_type == 'jswm': - self.power_on_tone = "你好,-bot_name来了,有什么吩咐" + elif dev_type == 'jswm'or dev_type == 'jswm_BOX': + self.power_on_tone = "我来陪你聊天了" elif dev_type == 'csh': self.power_on_tone = "欢迎使用助手小福" else: @@ -1282,12 +1342,12 @@ class AI_VC(Abstract): self.vad_silence = EventMesh.publish("get_storage_config","vad_silence")#语速配置 if self.vad_silence == None: if dev_type == "7PIN": - self.vad_silence = 1500 + self.vad_silence = 200 else: self.vad_silence = 300 self.VC_TTS_voice_type = EventMesh.publish("get_storage_config","VC_TTS_voice_type")#音色配置 - if self.VC_TTS_voice_type == None or ("男" in self.VC_TTS_voice_type) == False: + if self.VC_TTS_voice_type == None : if dev_type == "G10" or dev_type == "7PIN_BK"or dev_type == "szbst" : self.VC_TTS_voice_type = { "女":{ @@ -1315,6 +1375,18 @@ class AI_VC(Abstract): "voice":"zh_female_daimengchuanmei_moon_bigtts", "lang":"&lang=zh-cn-sc" }, + "瑞小蜜":{ + "bot_name":"瑞小蜜", + "voice":"zh_male_tiancaitongsheng_mars_bigtts", + "lang":"&lang=zh-cn-sc" , + "bot_id":"7491251662036811816",#瑞小蜜 + }, + "瑞小粉":{ + "bot_name":"瑞小粉", + "voice":"ICL_zh_female_tiaopigongzhu_tob", + "bot_id":"7501268622456045603",#瑞小粉 + "lang":"&lang=zh-cn-sc" + }, "个性":{ "bot_name":"小瑞", "voice":"zh_male_sunwukong_mars_bigtts" , @@ -1356,7 +1428,7 @@ class AI_VC(Abstract): } } - elif dev_type == "7PIN_BK_en": + elif dev_type == "7PIN_BK_EU": self.VC_TTS_voice_type = { "女":{ "bot_name":"Rose", @@ -1403,7 +1475,7 @@ class AI_VC(Abstract): "lang":"&lang=zh-cn-sc" }, } - elif dev_type == 'jswm': + elif dev_type == 'jswm'or dev_type == 'jswm_BOX': self.VC_TTS_voice_type = { "林悦":{ @@ -1442,7 +1514,7 @@ class AI_VC(Abstract): self.VC_TTS_voice_type = { "女":{ "bot_name":"食梦貘", - "voice":"zh_female_shaoergushi_mars_bigtts" , + "voice":"zh_female_linjia_mars_bigtts" , "lang":"zh-cn" }, "男":{ @@ -1525,12 +1597,12 @@ class AI_VC(Abstract): try: self.VC_TTS_voice_key = EventMesh.publish("get_storage_config","VC_TTS_voice_key")#音色配置 if self.VC_TTS_voice_key == None : - if dev_type == "7PIN_BK"or dev_type == "7PIN_BK_en"or dev_type == "7PIN_BK_coze": + if dev_type == "7PIN_BK"or dev_type == "7PIN_BK_EU"or dev_type == "7PIN_BK_coze": self.VC_TTS_voice_key = "ç«¥" #self.VC_TTS_voice_key = "男" - elif dev_type == "momo": - self.VC_TTS_voice_key = "男" - elif dev_type == "jswm": + elif dev_type == 'momo': + self.VC_TTS_voice_key = "女" + elif dev_type == "jswm"or dev_type == 'jswm_BOX': self.VC_TTS_voice_key = "林悦" else: self.VC_TTS_voice_key = "男" @@ -1544,7 +1616,7 @@ class AI_VC(Abstract): usys.print_exception(e) #配置词 self.commands_mode = 2 #=1用大模型判断命令,=0用服务器本地插件判断命令 =2用设备本地判断方式 - if dev_type == "7PIN_BK"or dev_type == "7PIN_BK_en"or dev_type == "7PIN_BK_coze": + if dev_type == "7PIN_BK"or dev_type == "7PIN_BK_EU"or dev_type == "7PIN_BK_coze": self.commands_mode = 2 self.commands = [ { @@ -1894,7 +1966,11 @@ class AI_VC(Abstract): response = None #http://180.184.206.142/bz-api/dev/config?deviceId=xxx try: - url = "http://dmp.raisound.com/bz-api/dev/config/{}".format(modem.getDevImei()) + url=None + if dev_type == "7PIN_BK_EU":#英文小瑞 + url = "http://dmp-global.raisound.com/bz-api/dev/config/{}".format(modem.getDevImei()) + else: + url = "http://dmp.raisound.com/bz-api/dev/config/{}".format(modem.getDevImei()) print(url) response = request.get(url,timeout=5) if response.status_code == 200: @@ -1964,8 +2040,8 @@ class AI_VC(Abstract): self.VC_Speech_Start() self.AI_VC_start() - if dev_type != "7PIN": - self.chenggong_tone() + # if dev_type != "7PIN": + # self.chenggong_tone() # self.Close() # self.AI_VC_start() self.AI_key_long_press_flag = 0 @@ -1993,7 +2069,7 @@ class AI_VC(Abstract): # except Exception as e: # usys.print_exception(e) #EventMesh.publish("publish_AI_btnInfo",{"func":self.key_prompt}) #提示请您按住中间的按钮开始讲话,讲完松开即可 - if dev_type == "7PIN_BK_en": + if dev_type == "7PIN_BK_EU": self.AI_TTS_str = "Please press and hold the button to speak. " else: self.AI_TTS_str = "请您按住中间的按钮开始讲话,讲完松开即可 " @@ -2314,23 +2390,7 @@ class AI_VC(Abstract): print("not lang!!!!!!!!!!!!!!!!!!!!!!") except Exception as e: usys.print_exception(e) - if dev_type == "G10": - platform = "platform=huoshan&is_boot=1" - #platform = "platform=raisound" - #platform = "platform=aliyun" - elif dev_type == "7PIN_BK"or dev_type == "7PIN_BK_en"or dev_type == "7PIN_BK_coze": - platform = "platform=huoshan" - #platform = "platform=raisound&bot_type=dify" - platform = "platform=raisound&bot_type=fourseason_water" - pass - elif dev_type == 'momo':# - #22080/voice-chat/v2.1/ws?platform=raisound&bot_type=deepseek - platform = "platform=raisound&bot_type=shimeng_mo" - elif dev_type == "sjgq": - platform = "platform=raisound" - else: - platform = "platform=huoshan" - #platform = "platform=huoshan&is_boot=1" + #女,男,童,粤,川 self.bot_name = "柒先生" try: @@ -2345,20 +2405,13 @@ class AI_VC(Abstract): # self.AI_client_VC = uwebsocket.Client.connect('wss://nls-gateway-cn-beijing.aliyuncs.com/ws/v1',headers=Headers, debug=False) token = EventMesh.publish("get_dev_token") print("token:{}".format(token)) - if dev_type == 'momo' :# - req_str = "voice-chat/v2.1/ws?is_auth={}&{}&{}".format(self.is_auth,platform,lang) - elif dev_type == '7PIN_BK'or dev_type == "7PIN_BK_en"or dev_type == "7PIN_BK_coze": - #req_str = "voice-chat/v2.1/ws?is_auth={}&{}&{}".format(self.is_auth,platform,lang) - req_str = "voice-chat/ws?is_auth={}&{}&{}".format(self.is_auth,platform,lang) - elif dev_type == "sjgq": - req_str = "22085/voice-chat/ws?is_auth={}&{}&{}".format(self.is_auth,platform,lang) - elif dev_type == "G10": - req_str = "vc/chat?is_auth={}".format(self.is_auth) - else: - req_str = "voice-chat/ws?is_auth={}&{}&{}".format(self.is_auth,platform,lang) + req_str = "vc/chat?is_auth={}".format(self.is_auth) if dev_type == '7PIN_BK_coze': req_str = "vc/coze?is_auth={}".format(self.is_auth) + elif dev_type == 'jswm' or dev_type == 'jswm_BOX': + req_str = "vc/agent?is_auth={}".format(self.is_auth) + if(token): url = 'ws://{}/{}&dt={}'.format(self.server_ip,req_str,token) else: @@ -2655,10 +2708,12 @@ class AI_VC(Abstract): # self.VC_dialog_id = payload["dialog_id"] # self.VC_task_id = jsload_data["task_id"] EventMesh.publish("open_led_blue") + print("VC:Started!!!!!!!!\r\n") if self.AI_TTS_str == "": #开始上传语音 - + if dev_type != "7PIN": + self.chenggong_tone() if self.VC_mode == 0 : self.VC_record_state_flag =2 else: @@ -2667,7 +2722,11 @@ class AI_VC(Abstract): else: EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_VC_synthesis}) - self.VC_state = VC_State_None + self.VC_state = VC_State_None + elif jsload_data["event"] == "config.update" :#配置更新中,需要停止录音 + self.VC_state = VC_State_End + EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End}) + elif jsload_data["event"] == "asr.started" :#asr开始 self.VC_state = VC_State_SpeechStart if self.VC_mode == 1 : @@ -3225,88 +3284,88 @@ class AI_VC(Abstract): return -1 try: if isinstance(text, str): - if dev_type == 'jswm':#金三完美 - if len(text)<25 and (text.find("你好") != -1 or text.find("您好") != -1) : + if dev_type != 'jswm' and dev_type != 'jswm_BOX':#金三完美,不使用设备切换角色 + # if len(text)<25 and (text.find("你好") != -1 or text.find("您好") != -1) : + # try: + # for key in self.VC_TTS_voice_type: + # if text.find(key) != -1 : + # self.VC_TTS_voice_key = key + # EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) + # self.AI_TTS_str = "嗨,{}来了,有什么吩咐".format(self.VC_TTS_voice_key) + # return 0 + # except Exception as e: + # usys.print_exception(e) + # return -1 + if text.find("声音") != -1 and text.find("改") != -1: try: for key in self.VC_TTS_voice_type: if text.find(key) != -1 : self.VC_TTS_voice_key = key EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) - self.AI_TTS_str = "嗨,{}来了,有什么吩咐".format(self.VC_TTS_voice_key) + self.AI_TTS_str = "更改成功" return 0 except Exception as e: - usys.print_exception(e) - return -1 - if text.find("声音") != -1 and text.find("改") != -1: - try: - for key in self.VC_TTS_voice_type: - if text.find(key) != -1 : - self.VC_TTS_voice_key = key + usys.print_exception(e) + if text.find("男") != -1 : + if "男" in self.VC_TTS_voice_type: + self.VC_TTS_voice_key = "男" EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) + # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) + #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 self.AI_TTS_str = "更改成功" return 0 - except Exception as e: - usys.print_exception(e) - if text.find("男") != -1 : - if "男" in self.VC_TTS_voice_type: - self.VC_TTS_voice_key = "男" - EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) - # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) - #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 - self.AI_TTS_str = "更改成功" - return 0 - if text.find("女") != -1 : - if "女" in self.VC_TTS_voice_type: - self.VC_TTS_voice_key = "女" - EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) - # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) - #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 - self.AI_TTS_str = "更改成功" - return 0 - if text.find("同声") != -1 or text.find("ç«¥") != -1 : - if "ç«¥" in self.VC_TTS_voice_type: - self.VC_TTS_voice_key = "ç«¥" - EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) - # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) - #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 - self.AI_TTS_str = "更改成功" - return 0 - if text.find("粤") != -1 or text.find("越野") != -1 or text.find("广东话") != -1: - if "粤" in self.VC_TTS_voice_type: - self.VC_TTS_voice_key = "粤" - EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) - # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) - #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 - self.AI_TTS_str = "更改成功" - return 0 - if text.find("四川") != -1 : - if "四川" in self.VC_TTS_voice_type: - self.VC_TTS_voice_key = "四川" - EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) - # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) - #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 - self.AI_TTS_str = "更改成功" - return 0 - if text.find("个性") != -1 : - if "个性" in self.VC_TTS_voice_type: - self.VC_TTS_voice_key = "个性" - EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) - # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) - #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 - self.AI_TTS_str = "更改成功" - return 0 - if text.find("英语") != -1 : - if "英语" in self.VC_TTS_voice_type: - self.VC_TTS_voice_key = "英语" - EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) - # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) - #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 - self.AI_TTS_str = "更改成功" - return 0 - self.AI_TTS_str = "更改失败,没找到对应声音" - return 0 + if text.find("女") != -1 : + if "女" in self.VC_TTS_voice_type: + self.VC_TTS_voice_key = "女" + EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) + # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) + #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 + self.AI_TTS_str = "更改成功" + return 0 + if text.find("同声") != -1 or text.find("ç«¥") != -1 : + if "ç«¥" in self.VC_TTS_voice_type: + self.VC_TTS_voice_key = "ç«¥" + EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) + # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) + #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 + self.AI_TTS_str = "更改成功" + return 0 + if text.find("粤") != -1 or text.find("越野") != -1 or text.find("广东话") != -1: + if "粤" in self.VC_TTS_voice_type: + self.VC_TTS_voice_key = "粤" + EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) + # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) + #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 + self.AI_TTS_str = "更改成功" + return 0 + if text.find("四川") != -1 : + if "四川" in self.VC_TTS_voice_type: + self.VC_TTS_voice_key = "四川" + EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) + # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) + #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 + self.AI_TTS_str = "更改成功" + return 0 + if text.find("个性") != -1 : + if "个性" in self.VC_TTS_voice_type: + self.VC_TTS_voice_key = "个性" + EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) + # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) + #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 + self.AI_TTS_str = "更改成功" + return 0 + if text.find("英语") != -1 : + if "英语" in self.VC_TTS_voice_type: + self.VC_TTS_voice_key = "英语" + EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key]) + # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"]) + #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功 + self.AI_TTS_str = "更改成功" + return 0 + self.AI_TTS_str = "更改失败,没找到对应声音" + return 0 if text.find("切换对话模式") != -1: - if dev_type == "7PIN_BK_en": + if dev_type == "7PIN_BK_EU": if self.VC_mode == 0: self.VC_mode = 1 self.AI_TTS_str = "change dialogue mode" @@ -3694,7 +3753,9 @@ class AI_VC(Abstract): "trace_id": self.get_trace_id(), }, "payload": { + "simple_response": True,#不返回llm过程文本 "device_id": modem.getDevImei(), + "user_agent": "AudioClient/1.0", "dialog_attributes": { #"provider": "doubao", @@ -3732,7 +3793,7 @@ class AI_VC(Abstract): #"voice": "7426720361732980745", "voice": voice,#音色 "speech_rate": self.speech_rate,#语速 - "chunk_interval_ms": 10, # 配置每段音频入队间隔时间 100ms + "chunk_interval_ms": 30, # 配置每段音频入队间隔时间 100ms } }, "inbound_attributes": { @@ -3773,9 +3834,22 @@ class AI_VC(Abstract): #json_data["payload"]["dialog_attributes"]["provider"]="doubao"#豆包 json_data["payload"]["inbound_attributes"]["provider"]="volcengine"#火山 #json_data["payload"]["inbound_attributes"]["vad_silence"] = 200 + #if self.VC_TTS_voice_type[self.VC_TTS_voice_key]["bot_id"] !="": + if "bot_id" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]: + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]=self.VC_TTS_voice_type[self.VC_TTS_voice_key]["bot_id"] + if "workflow_id" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]: + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]= self.VC_TTS_voice_type[self.VC_TTS_voice_key]["workflow_id"] + else: + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="" + if json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"] == "": + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["use_workflow"]=False - elif dev_type == "7PIN_BK_en": + keywords = []#热词 + for key in self.VC_TTS_voice_type: + keywords.append(key) + json_data["payload"]["inbound_attributes"]["cfg"]["keywords"] = keywords + elif dev_type == "7PIN_BK_EU": json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7493368740600446995"#英文 json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="7493369551587213323" json_data["payload"]["inbound_attributes"]["provider"]="volcengine"#火山 @@ -3785,12 +3859,29 @@ class AI_VC(Abstract): json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="" json_data["payload"]["inbound_attributes"]["provider"]="volcengine"#火山 elif dev_type == "7PIN":#柒牌 - json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7411071327182438412"# - json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="7469049680291610636" + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]=""# + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="" #json_data["payload"]["inbound_attributes"]["vad_silence"] = 1000 # elif dev_type == 'momo':#食梦貘 - pass + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7491256313561825332" + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="" + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["use_workflow"]=False + json_data["payload"]["inbound_attributes"]["provider"]="volcengine"#火山 + if "bot_id" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]: + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]=self.VC_TTS_voice_type[self.VC_TTS_voice_key]["bot_id"] + if "workflow_id" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]: + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]= self.VC_TTS_voice_type[self.VC_TTS_voice_key]["workflow_id"] + else: + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="" + if json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"] == "": + json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["use_workflow"]=False + + + keywords = []#热词 + for key in self.VC_TTS_voice_type: + keywords.append(key) + json_data["payload"]["inbound_attributes"]["cfg"]["keywords"] = keywords elif dev_type == 'sjgq':#四季甘泉 json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7472201279826690111" json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="472203898494500914" @@ -3798,7 +3889,8 @@ class AI_VC(Abstract): elif dev_type == 'szbst':#深圳百事通 json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7469964258592931852" json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="7469968083063603241" - elif dev_type == 'jswm':#金三完美 + elif dev_type == 'jswm' or dev_type == 'jswm_BOX':#金三完美 + #json_data["payload"]["device_id"]= "WangQunTestID" if self.VC_TTS_voice_type[self.VC_TTS_voice_key]["bot_id"] !="": json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]=self.VC_TTS_voice_type[self.VC_TTS_voice_key]["bot_id"] if self.VC_TTS_voice_type[self.VC_TTS_voice_key]["workflow_id"] == "": @@ -3813,9 +3905,10 @@ class AI_VC(Abstract): for key in self.VC_TTS_voice_type: keywords.append(key) json_data["payload"]["inbound_attributes"]["cfg"]["keywords"] = keywords - if self.commands_mode !=0: + + if self.commands_mode !=0 : json_data["payload"]["commands"] = [] - if self.VC_mode == 0:#长对话模式打开vad + if self.VC_mode == 0 :#and dev_type != "7PIN_BK_coze":#长对话模式打开vad json_data["payload"]["inbound_attributes"]["disable_vad"] = False self.VC_state = VC_State_None self.AI_client_VC_send(ujson.dumps(json_data)) @@ -4122,4 +4215,20 @@ class AI_VC(Abstract): # if num == None: # num = 8 # self.aud.setVolume(num)#恢复原始音量 - \ No newline at end of file + + +{ + "version": "202505151440", + "VC_TTS_voice_type": { + "班度": { + "bot_name": "班度", + "voice": "huoshan::zh_male_yuanboxiaoshu_moon_bigtts", + "lang": "zh-cn", + "bot_id":"7490824341572075555",#AI语音APP女神经理 + "workflow_id":"", + }, + + }, + "power_on_tone": "阿弥陀佛,施主既来,便是有缘。心中若有烦忧,直说无妨。" + +} \ No newline at end of file