if "电量" in msg:
battery = EventMesh.publish("get_battery")
print("电量查询:{}".format(battery))
- self.AI_TTS_str = "电量剩余百分之{}.format(battery)"
+ tts_play_str = "电量剩余百分之{}".format(battery)
+ # print("电量!!!!!!!!!!!")
elif "信号" in msg:
signal = net.csqQueryPoll()
- self.AI_TTS_str = "当前信号{}".format(signal)
+ tts_play_str = "当前信号{}".format(signal)
+ # print("信号!!!!!!!!!!!")
elif "卡号" in msg:
+ # print("卡号!!!!!!!!!!!")
iccid = sim.getIccid()
if iccid != -1 and len(iccid) > 5:
print("iccid{}".format(iccid))
- self.AI_TTS_str = "当前卡号为:{}".format(iccid)
+ tts_play_str = "当前卡号为:{}".format(iccid)
else:
- self.AI_TTS_str = "卡号查询失败"
+ tts_play_str = "卡号查询失败"
+ EventMesh.publish("play_tts",[tts_play_str,0])
#改变音色判断
def change_voice(self,event ,msg):
voice = msg
AringTimes = 1
repeat_sentence = (alarm_TTS_str + ",") # 重复5次并加逗号分隔
final_sentence = repeat_sentence.rstrip(",")
- final_sentence = "日程提醒: " + final_sentence
+ final_sentence = "日程提醒: 您设置的" + final_sentence + "时间到了,请留意"
self.schedule_play_count = AringTimes
EventMesh.publish("play_tts",[final_sentence,1]) #播放tts闹钟文本内容
self.schedule_array.pop(current_index)
pcr.add_support(pro.IOTWeb_user_unbind_devProtoCol())
pcr.add_support(pro.IOTWeb_play_MusicProtoCol())
pcr.add_support(pro.IOTWeb_Nlp_ConfigProtoCol())
- pcr.add_support(pro.IOTWeb_play_trans_TTSProtoCol())
+ pcr.add_support(pro.IOTWeb_play_trans_TTSProtoCol())#播放下发翻译音频
+ pcr.add_support(pro.IOTWeb_come_transProtoCol())#接收小程序控制进入翻译
sm = pro.SockMangager()
sm.add_support_resolver(pcr)
ai_cmd_handle(cmdName)
print("recv push_music{}".format(msg))
+#接收小程序控制进入翻译
+class IOTWeb_come_transProtoCol(ProtoCol):
+ """translate_app_enter"""
+ TYPE = "translate_app_enter"
+
+ def send(self, event, msg):
+ # print("translate_app_enter{}".format(msg))
+ # 通过websocket发送到服务器端
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ come_trans = {
+ "cmd":"translate_device_complete",
+ "ts":time_tmp,
+ "msg":"进入成功",
+ "data":None
+ }
+ send_data = b''
+ send_data = protocol_send_total_data(come_trans)
+ print("send_data translate_app_enter{}".format(send_data))
+ EventMesh.publish("CHANNEL_IOT_WEB_SEND", send_data)
+
+ def recv(self, event, msg):
+ """
+ @param event:上行下发push_music
+ @param msg: 接收到的下行数据
+ """
+ EventMesh.publish("come_trans_mode")#进入AI翻译纪要
+ print("recv tts_audio_url{}".format(msg))
+
#翻译播放TTS
class IOTWeb_play_trans_TTSProtoCol(ProtoCol):
"""tts_audio_url"""
EventMesh.publish("set_storage_config",["switch_bt_state","1"])
EventMesh.publish("send_bt_switch_toble","1")
EventMesh.publish(WEB_CMD_ENUM.USER_UNBIND_DEV_S)
+ tts_play_str = "设备已解绑"
+ EventMesh.publish("play_tts",[tts_play_str,1])
# ret = 0
# ret = ql_fs.path_exists("/usr/static/storage_file")#配置文件
# if ret == True: