self.voice_flag = 1
print("语音留言回复停止")
self.revoice_timer.start(1000,1,self.revoice_judge)
- if EventMesh.publish("get_play_new_voice_state")== 1:
- EventMesh.publish("set_play_new_voice_state",0)
- # EventMesh.publish("update_play_new_voice_info")
- EventMesh.publish("play_new_voice_list")
+ # if EventMesh.publish("get_play_new_voice_state")== 1:
+ # EventMesh.publish("set_play_new_voice_state",0)
+ # # EventMesh.publish("update_play_new_voice_info")
+ # EventMesh.publish("play_new_voice_list")
print("是否未读:{},是否播完:{}".format(EventMesh.publish("get_wait_voice_flag"),len(EventMesh.publish("get_play_new_voice_list"))))
# if EventMesh.publish("get_wait_voice_flag") == 1 and len(EventMesh.publish("get_play_new_voice_list")) ==0:#还在未读并且列表为空
# self.wait_first_flag = 0
self.recv_voice = 0#进入留言定时器,留言清空
EventMesh.publish("set_history_voice_flag",0)
EventMesh.publish("set_wait_voice_flag",0)
+ EventMesh.publish("set_open_device",0)#开机不听
self.wait_first_flag = 0
if self.voice_choose_flag == 1:#播放完语音后,有冲突的时候关闭
self.voice_choose_flag = 0
#self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
return 0
- if text.find("音量") != -1:
- if text.find("加") != -1 :
- self.VC_TTS_volume += 10
- if self.VC_TTS_volume > 100:
- #EventMesh.publish("audio_montage_play",["yinliangyizuida.mp3"])
- #self.aud.play(1,0,'U:/static/yinliangyizuida.mp3')#音量已最大
- self.AI_TTS_str = "音量已最大"
- self.VC_TTS_volume = 100
- 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)
- #EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
- #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#配置成功
- self.AI_TTS_str = "配置成功,当前音量 {}".format(self.VC_TTS_volume)
+ # if text.find("音量") != -1:
+ # if text.find("加") != -1 :
+ # self.VC_TTS_volume += 10
+ # if self.VC_TTS_volume > 100:
+ # #EventMesh.publish("audio_montage_play",["yinliangyizuida.mp3"])
+ # #self.aud.play(1,0,'U:/static/yinliangyizuida.mp3')#音量已最大
+ # self.AI_TTS_str = "音量已最大"
+ # self.VC_TTS_volume = 100
+ # 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)
+ # #EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ # #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#配置成功
+ # self.AI_TTS_str = "配置成功,当前音量 {}".format(self.VC_TTS_volume)
- return 0
- if text.find("减") != -1:
- self.VC_TTS_volume -= 10
- if self.VC_TTS_volume < 0:
- self.VC_TTS_volume = 0
- #EventMesh.publish("audio_montage_play",["yinliangyizuixiao.mp3"])
- #self.aud.play(1,0,'U:/static/yinliangyizuixiao.mp3')#音量已最小
- self.AI_TTS_str = "音量已最小"
- 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)
- #EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
- #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#配置成功
- self.AI_TTS_str = "配置成功,当前音量 {}".format(self.VC_TTS_volume)
- return 0
+ # return 0
+ # if text.find("减") != -1:
+ # self.VC_TTS_volume -= 10
+ # if self.VC_TTS_volume < 0:
+ # self.VC_TTS_volume = 0
+ # #EventMesh.publish("audio_montage_play",["yinliangyizuixiao.mp3"])
+ # #self.aud.play(1,0,'U:/static/yinliangyizuixiao.mp3')#音量已最小
+ # self.AI_TTS_str = "音量已最小"
+ # 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)
+ # #EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ # #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#配置成功
+ # self.AI_TTS_str = "配置成功,当前音量 {}".format(self.VC_TTS_volume)
+ # return 0
if text.find("进入工厂模式") != -1 :
self.factory_mode()
EventMesh.publish("change_voice",find)
elif "结束对话" in cmd:#当指令中有结束对话时,结束当前对话
EventMesh.publish("Close_VC")
- elif "音量调节" in cmd:#当指令中有音量改为时,音量改为具体数值
- voice_start_index = cmd.index("音量调节:") + len("音量调节:")#动态判断截取部分
- find = cmd[voice_start_index:]#查询截取
- print("find = {}".format(find))
- if find == "+10":
- EventMesh.publish("change_volume",1)
- tts_play_str = "音量已经加大"
- elif find == "-10":
- EventMesh.publish("change_volume",0)
- tts_play_str = "音量已经减小"
- else:
+ elif "音量" in cmd:#当指令中有音量改为时,音量改为具体数值
+ if "调节" in cmd :
+ voice_start_index = cmd.index("音量调节:") + len("音量调节:")#动态判断截取部分
+ find = cmd[voice_start_index:]#查询截取
+ 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])
+ 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])
+ elif "减小" in cmd:
+ EventMesh.publish("change_volume",0)
+ tts_play_str = "音量已经减小"
+ EventMesh.publish("play_tts",[tts_play_str,0])
+
elif "查看历史留言" in cmd :#当指令中有查看历史留言时,调用历史留言接口
EventMesh.publish(WEB_CMD_ENUM.GET_NEW_VOICE_MSG_S)
EventMesh.publish("set_history_voice_flag",1)#修改标志位
voice_start_index = cmd.index("语速倍速设置为:") + len("语速倍速设置为:")#动态判断截取部分
find = cmd[voice_start_index:]#查询截取
print("find = {}".format(find))
- EventMesh.publish("SET_SPEECH_RATE",float(find))
- tts_play_str = "语速已经改为" + find
+ if find == "0.5" or find == "1.0" or find == "1.5" or find == "2.0":
+ EventMesh.publish("SET_SPEECH_RATE",float(find))
+ tts_play_str = "语速已经改为" + find
+ else:
+ tts_play_str = "这个不支持哦,请换一个"
EventMesh.publish("play_tts",[tts_play_str,0])
- elif "è¿\99ä¸\8dæ\94¯æ\8c\81å\93¦ï¼\8c请æ\8d¢ä¸\80个":
+ elif "è¿\99个ä¸\8dæ\94¯æ\8c\81å\93¦ï¼\8c请æ\8d¢ä¸\80个" in cmd:
tts_play_str = "这个不支持哦,请换一个"
EventMesh.publish("play_tts",[tts_play_str,0])
if len(new_voice_list) > 0:
pass
else:#未读留言
- if self.open_device == 1:
+ if self.open_device == 1 or EventMesh.publish("get_60S_voice_flag") == 1:
EventMesh.publish("set_pwk_cnt_voice",len(voice_list))#设置未读次数,由于是开机一起查看的
+ EventMesh.publish("set_60S_voice_flag",0)
for da in voice_list:
new_voice_list.append(da)
if len(new_voice_list) > 0:
super().__init__()
self._1M_flag = 0#判断一分钟定时器是否开启中
self.app_new_voice_flag = 0#app是否下发留言
+ self._1M_timer = osTimer()#多发留言间隙时间60S
+ self._60S_voice_flag = 0
EventMesh.subscribe("get_app_new_voice_flag",self.get_app_new_voice_flag)
EventMesh.subscribe("set_app_new_voice_flag",self.set_app_new_voice_flag)
EventMesh.subscribe("get_1M_flag",self.get_1M_flag)
+ EventMesh.subscribe("get_60S_voice_flag",self.get_60S_voice_flag)
+ EventMesh.subscribe("set_60S_voice_flag",self.set_60S_voice_flag)
+
def send(self, event, msg):
print("send new_voice_msg_list{}".format(msg))
# 通过websocket发送到服务器端
@param msg: 接收到的下行数据
"""
self.app_new_voice_flag = 1#标志位为1
- self._1M_timer = osTimer()#多发留言间隙时间60S
new_voice_list = []
if "data" in msg:
data = msg["data"]
def _1M_timer_cb_(self):
#self.iot_web_send_queue.put("ping")
- if len(EventMesh.publish("get_play_new_voice_list")) == 0:
- self._1M_timer.stop()
- self._1M_flag = 0
- get_VC_satrt_flag = EventMesh.publish("get_VC_satrt_flag")
- if get_VC_satrt_flag == None:
- get_VC_satrt_flag = 0
- if get_VC_satrt_flag == 0:
+ # get_VC_satrt_flag = EventMesh.publish("get_VC_satrt_flag")
+ # if get_VC_satrt_flag == None:
+ # get_VC_satrt_flag = 0
+ # if get_VC_satrt_flag == 0:
print("收到多条信息,统一播放")
self._1M_flag = 0
- EventMesh.publish("set_pwk_cnt_voice",len(EventMesh.publish("get_play_new_voice_list")))#设置未读次数
- EventMesh.publish(WEB_CMD_ENUM.GET_NEW_VOICE_MSG_S)
+ self._60S_voice_flag = 1
EventMesh.publish("set_history_voice_flag",1)#修改历史留言标志位
EventMesh.publish("set_wait_voice_flag",1)#修改60S标志位
- self._1M_timer.stop()
+ EventMesh.publish(WEB_CMD_ENUM.GET_NEW_VOICE_MSG_S)
+
def get_app_new_voice_flag(self,event,msg):
return self.app_new_voice_flag
def set_app_new_voice_flag(self,event,msg):
self.app_new_voice_flag = msg
def get_1M_flag(self,event,msg):
return self._1M_flag
-
+ def get_60S_voice_flag(self,event,msg):
+ return self._60S_voice_flag
+ def set_60S_voice_flag(self,event,msg):
+ self._60S_voice_flag = msg
class IOTWeb_put_voice_msg_stateProtoCol(ProtoCol):
"""put_voice_msg_state"""
TYPE = "put_voice_msg_state"