# 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()#获取/更新配置参数
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) #获取留言播放状态
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
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
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:
# 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 = "有新版本,准备开始升级,升级过程会多次重启设备,请保证流量充足及电量充足"
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("卡号!!!!!!!!!!!")
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:
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):