self.KeyAI_status = 0
if self.KeyAI_status == 0:#按下
- if EventMesh.publish("get_recv_voice") == 1:#当处于收到留言的时候
- print("收到留言")
- EventMesh.publish("set_voicerupt_flag",1)
- return
if EventMesh.publish("get_wait_voice_flag") == 1:
print("播放未读")
+ EventMesh.publish("set_wait_voicerupt_flag",1)
+ return
+ if EventMesh.publish("get_recv_voice") == 1:#当处于收到留言的时候
+ print("收到留言")
EventMesh.publish("set_voicerupt_flag",1)
return
if self.KeyAI_press == 0 :
url = "http://dmp-global.raisound.com/bz-api/dev/time"
else:
url = "https://dmp-api.qipai.com/qp-dmp-api/dev/time"
- # url = "http://dmp.raisound.com/bz-api/dev/time"
+ # url = "https://dmp-dev.raisound.com/dmp-api/dev/time"
response = request.get(url,timeout=5)
data = response.json()
print("dev_NTP:{}".format(data))
url = "http://dmp-global.raisound.com/bz-api/dev/auth/active"
else:
url = "https://dmp-api.qipai.com/qp-dmp-api/dev/auth/active"
- # url = "http://dmp.raisound.com/bz-api/dev/auth/active"
+ # url = "https://dmp-dev.raisound.com/dmp-api/dev/auth/active"
data =ujson.dumps(data)
response = None
response_result = 0
sign_url = "http://dmp-global.raisound.com/bz-api/dev/auth/sign_in" #登入地址
else:
sign_url = "https://dmp-api.qipai.com/qp-dmp-api/dev/auth/sign_in"
- # sign_url = "http://dmp.raisound.com/bz-api/dev/auth/sign_in" #登入地址
+ # sign_url = "https://dmp-dev.raisound.com/dmp-api/dev/auth/sign_in" #登入地址
#获取验证码
#url = "http://dmp.qipai.com.cn:30461/dev/device/bind-code/860132066060377"
# token = EventMesh.publish("get_dev_token")
url = "http://dmp-global.raisound.com/bz-api/dev/iccid?deviceId={}&iccid={}".format(modem.getDevImei(),iccid)
else:
url = "https://dmp-api.qipai.com/qp-dmp-api/dev/iccid?deviceId={}&iccid={}".format(modem.getDevImei(),iccid)
- # url = "http://dmp.raisound.com/bz-api/dev/iccid?deviceId={}&iccid={}".format(modem.getDevImei(),iccid) #北科地址
+ # url = "https://dmp-dev.raisound.com/dmp-api/dev/iccid?deviceId={}&iccid={}".format(modem.getDevImei(),iccid) #北科地址
print("{} H:{}".format(url,headers_T))
response = request.post(url,headers = headers_T)
if response.status_code == 200:
dev_tokenip = "http://dmp-global.raisound.com/bz-api/dev/auth/token" #设备新令牌更新地址
else:
dev_tokenip = "https://dmp-api.qipai.com/qp-dmp-api/dev/auth/token"
- # dev_tokenip = "http://dmp.raisound.com/bz-api/dev/auth/token" #设备新令牌更新地址
+ # dev_tokenip = "https://dmp-dev.raisound.com/dmp-api/dev/auth/token" #设备新令牌更新地址
token = self.dev_token
if token == None:
self.voice_timer = osTimer()#语音留言10S按下按键确定是否播放的判断定时器
self.voice_cnt = 0 #留言定时器计数
self.voicerupt_flag = 0#留言选择按键接听标志位
+ self.wait_voicerupt_flag = 0#未读留言选择按键接听标志位
self.recv_voice = 0 #是否收到留言
self.voice_notice = 0 #收到留言并播放则置为1,接下来要播放提示词
self.voice_choose_flag = 0#当tts和语音留言冲突时,为了防止语音地址被误清,做标志位在close做判断
elif dev_type == "7PIN" or dev_type == "7PIN_1_5":
#self.server_ip="sevenpin.qipai.com.cn"
# self.server_ip="220.160.104.34"
- # self.server_ip="118.145.158.207:22082"
+ # self.server_ip="118.145.158.207:22080"
+ # self.server_ip="amp-dev-global.raisound.com:22080"
# self.server_ip="118.145.158.207:22080/22087"
#self.server_ip="ai.qipai.com"
self.server_ip="dmp-api.qipai.com/qp-amp-api"
self.power_on_tone = "欢迎使用助手小福"
else:
self.power_on_tone = "您好!我是世界首创柒牌男装AI生活好帮手-bot_name, 很高兴为您服务,我可以帮您解答柒牌公司知识库、日常生活与工作、旅游信息、健康与运动咨询、教育与学习、情感交流、全球资讯、世界文化等问题!请问您有什么需要我帮忙的吗?"
+ self.power_on_tone = "你好,我来了"
self.VC_record_TYPE = VC_record_TYPE_PCM #0:PCM 1:AMR
self.VC_play_TYPE = VC_play_TYPE_PCM #0:PCM 1:mp3
EventMesh.subscribe("set_trans_flag",self.set_trans_flag)#设置翻译状态
EventMesh.subscribe("get_audio_play_state",self.get_audio_play_state)
EventMesh.subscribe("set_voicerupt_flag",self.set_voicerupt_flag)#按键中断触发留言播放
+ EventMesh.subscribe("set_wait_voicerupt_flag",self.set_wait_voicerupt_flag)#按键中断触发未读留言播放
EventMesh.subscribe("get_recv_voice",self.get_recv_voice)#获取是否收到留言
EventMesh.subscribe("rate_change",self.rate_change)#直接修改语速
EventMesh.subscribe("get_history_voice_flag",self.get_history_voice_flag)#获取查找历史留言状态
if self.inbound_attributess_provider == None:
if dev_type == "7PIN" or dev_type == "7PIN_1_5" or dev_type == "7PIN_coze" :
self.inbound_attributess_provider = "xun-fei"
+ self.inbound_attributess_provider = "volcengine"
else:
self.inbound_attributess_provider = "volcengine"
EventMesh.publish("send_meet_end_flag_to_iot")#结束会议
self.meet_flag=0
EventMesh.publish("stop_voice_record") #关闭语音录音
- exit_tts ="已退出会议纪要模式"
+ exit_tts ="å½\95é\9f³ç»\93æ\9d\9fï¼\8cå·²é\80\80å\87ºä¼\9a议纪è¦\81模å¼\8f"
EventMesh.publish("play_tts",[exit_tts,1])
pass
def come_trans_mode(self, event=None, msg = None):
pass
def ai_key_press_audio_cb1(self, event=None, msg = None):
print("播放按键音!!!!!!!!!!")
- EventMesh.publish("audio_montage_play",["chenggong.mp3"])
+ # EventMesh.publish("audio_montage_play",["chenggong.mp3"])
# self.chenggong_tone()
- # self.aud.aud_tone_play(10,400)#播放按键音
+ self.aud.aud_tone_play(10,400)#播放按键音
def ai_key_press_audio_cb2(self, event=None, msg = None):
EventMesh.publish("audio_montage_play",["chenggong.mp3"])
# self.chenggong_tone() #播放按键音
self.get_config_timer_count = 0
self.key_state = 1
if dev_type == "7PIN": #2代产品要延时播放按键音 为了连接蓝牙后不播放按键音的问题
- # self.aud.aud_tone_play(10,400)#播放按键音
- EventMesh.publish("audio_montage_play",["chenggong.mp3"])
+ self.aud.aud_tone_play(10,400)#播放按键音
+ # EventMesh.publish("audio_montage_play",["chenggong.mp3"])
# self.chenggong_tone() #播放按键音
elif dev_type == "7PIN_1_5": #2代产品要延时播放按键音 为了连接蓝牙后不播放按键音的问题
self.ai_key_press_audio.stop()
print("AI_key_press")
self.get_config_timer_count = 0
self.key_state = 1
- # self.aud.aud_tone_play(10,400)#播放按键音
- EventMesh.publish("audio_montage_play",["chenggong.mp3"])
+ self.aud.aud_tone_play(10,400)#播放按键音
+ # EventMesh.publish("audio_montage_play",["chenggong.mp3"])
# self.chenggong_tone() #播放按键音
if PRESS_AUDIO_MODE == 1:
if dev_type == "7PIN" or dev_type == "7PIN_1_5":
print("pwk_key_release")
# EventMesh.publish("set_temp")
# return
- EventMesh.publish("exit_meet_mode")#退出会议纪要
- EventMesh.publish("exit_trans_mode")#退出AI翻译
if EventMesh.publish("get_recv_voice") == 1:
EventMesh.publish("update_play_new_voice_info")#更新已读状态
self.recv_voice = 0#退出留言以及留言查看
EventMesh.publish("set_history_voice_flag",0)#修改标志位
self.AI_new_voice_url = ""
+ if self.trans_flag == 1 or self.meet_flag == 1:
+ EventMesh.publish("exit_meet_mode")#退出会议纪要
+ EventMesh.publish("exit_trans_mode")#退出AI翻译
+ return
EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
EventMesh.publish("stop_sos_call")
#EventMesh.publish("sleep_BT")#休眠蓝牙
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)
-
+ # elif dev_type == "7PIN":#内部测试,不用coze
+ # req_str = "vc/agent?is_auth={}".format(self.is_auth)
if(token):
url = 'ws://{}/{}&dt={}'.format(self.server_ip,req_str,token)
else:
self.pwk_notice_flag = 0
self.wait_sort = 0
self.wait_first_flag = 0#让下次未读播放提示恢复
+ self.voicerupt_flag = 0 #标志位置0
+ self.wait_voicerupt_flag = 0
self.voice_notice = 1#开启回复
if self.history_voice_flag == 1 and self.wait_voice_flag == 0:
self.voice_notice = 0
self.pwk_notice_flag = 1#表示进入收听未听留言
self.AI_VC_start()
EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_new_voice})#播放留言
- self.voicerupt_flag = 0 #标志位置0
self.voice_cnt = 0
# self.recv_voice = 0#进入留言定时器,留言清空
print("进入留言定时器1,留言清空!!!!!")
EventMesh.publish("publish_AI_btnInfo",{"func":self.wait_play_cb})
def wait_play_cb(self):
self.wait_cnt += 1
- if self.voicerupt_flag == 1:#按键被按下
+ if self.wait_voicerupt_flag == 1:#按键被按下
EventMesh.publish("set_is_listen_wait",1)#已听
self.pwk_notice_flag = 1#表示进入收听未听留言
self.AI_VC_start()
# self.wait_cnt = 0
# print("进入留言定时器1,留言清空!!!!!")
# EventMesh.publish("update_play_new_voice_info")#更新已读状态
- self.voicerupt_flag = 0
self.wait_timer.stop()
if self.wait_cnt > 10:#10S后退出播放,5S是为了给语音提示留时间
self.wait_cnt = 0
EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_new_voice})#播放留言
self.wait_cnt = 0
self.wait_timer.stop()
- def set_voicerupt_flag(self,event,msg):#按键控制留言播放
+ def set_voicerupt_flag(self,event,msg):#按键控制当前留言播放
self.voicerupt_flag = msg
+ def set_wait_voicerupt_flag(self,event,msg):#按键控制未读留言播放
+ self.wait_voicerupt_flag = msg
def get_voicerupt_flag(self,event,msg):#获取按键控制留言播放状态
return self.voicerupt_flag
def get_recv_voice(self,event,msg):
"user_agent": "AudioClient/1.0",
"dialog_attributes": {
#"provider": "doubao",
- "provider": "coze",
+ # "provider": "coze",
"cfg": {
"disable_empty_prompt" : True,#拦截空字符请求大模型
}
},
"inbound_attributes": {
- "provider": "xun-fei",#
- #"provider": "volcengine",
+ # "provider": "xun-fei",#
+ "provider": "volcengine",
"disable_vad":True,
"vad_silence":self.vad_silence,
"interrupt_options":{
json_data["payload"]["outbound_attributes"]["provider"]=self.outbound_attributess_provider#TTS音色服务选择,火山
json_data["payload"]["inbound_attributes"]["provider"]=self.inbound_attributess_provider#ASR服务选择,火山
#优先选择self.VC_TTS_voice_type[self.VC_TTS_voice_key]里得参数
- if "inbound_attributess_provider" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]:
- if len(self.VC_TTS_voice_type[self.VC_TTS_voice_key]["inbound_attributess_provider"])>0:
- json_data["payload"]["inbound_attributes"]["provider"]=self.VC_TTS_voice_type[self.VC_TTS_voice_key]["inbound_attributess_provider"]
- print("inbound_attributess_provider是VC_TTS_voice_type里的:{}".format(self.VC_TTS_voice_type[self.VC_TTS_voice_key]["inbound_attributess_provider"]))
+ # if "inbound_attributess_provider" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]:
+ # if len(self.VC_TTS_voice_type[self.VC_TTS_voice_key]["inbound_attributess_provider"])>0:
+ # json_data["payload"]["inbound_attributes"]["provider"]=self.VC_TTS_voice_type[self.VC_TTS_voice_key]["inbound_attributess_provider"]
+ # print("inbound_attributess_provider是VC_TTS_voice_type里的:{}".format(self.VC_TTS_voice_type[self.VC_TTS_voice_key]["inbound_attributess_provider"]))
if "outbound_attributess_provider" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]:
if len(self.VC_TTS_voice_type[self.VC_TTS_voice_key]["outbound_attributess_provider"])>0:
json_data["payload"]["outbound_attributes"]["provider"]=self.VC_TTS_voice_type[self.VC_TTS_voice_key]["outbound_attributess_provider"]
json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["use_workflow"]=False
json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]=""
elif dev_type == "7PIN" or dev_type == "7PIN_1_5" :#柒牌
- json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7550138354483298347"#
- json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="7549142130376671267"
+ # json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7550138354483298347"#
+ # json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="7549142130376671267"
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7411071327182438412"
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="7601036330500669467"
#json_data["payload"]["inbound_attributes"]["vad_silence"] = 1000
elif dev_type == "7PIN_coze":
json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7550138354483298347"#
return
elif EventMesh.publish("get_voice_record_mode") == 1: #静默录音需要打断
EventMesh.publish("stop_voice_record")#停止静默录音
- # self.aud.aud_tone_play(10,400)
- EventMesh.publish("audio_montage_play",["chenggong.mp3"])
+ self.aud.aud_tone_play(10,400)
+ # EventMesh.publish("audio_montage_play",["chenggong.mp3"])
if PRESS_AUDIO_MODE == 1:
if dev_type == "7PIN" or dev_type == "7PIN_1_5" :
# self.aud.aud_tone_play(10,200)
#改变音色判断
def change_voice(self,event ,msg):
voice = msg
+ # if "男声" in msg or "普通话" in msg:
+ # self.VC_TTS_voice_key = "男"
+ # else:
+ # self.VC_TTS_voice_key = voice
+ self.outbound_attributess_provider = "xun-fei"
if "男声" in msg or "普通话" in msg:
self.VC_TTS_voice_key = "男"
+ self.outbound_attributess_provider = "volcengine"
elif "女声" in msg:
self.VC_TTS_voice_key = "女"
+ self.outbound_attributess_provider = "volcengine"
elif "童声" in msg:
self.VC_TTS_voice_key = "童"
+ self.outbound_attributess_provider = "volcengine"
elif "香港粤语" in msg:
self.VC_TTS_voice_key = "香港粤语"
elif "四川话" in msg:
def chenggong_tone(self):
- EventMesh.publish("audio_montage_play",["chenggong.mp3"])
+ # EventMesh.publish("audio_montage_play",["chenggong.mp3"])
+ self.aud.aud_tone_play(10,400)
def send_tone(self):
EventMesh.publish("audio_montage_play",["send_tone.mp3"])
def concurrency_limit_exceeded_tone(self):