pass
def come_trans_mode(self, event=None, msg = None):
if self.trans_flag == 0: #还是为0就提示进入AI翻译模式
- EventMesh.publish("send_trans_come_flag_to_iot")#退出翻译
+ EventMesh.publish("send_trans_come_flag_to_iot")#进入翻译
self.trans_flag=1
exit_tts ="已进入AI翻译模式"
EventMesh.publish("play_tts",[exit_tts,1])
pass
def exit_trans_mode(self, event=None, msg = None):
- if self.trans_flag == 1: #还是为1就提示已退出AI翻译模式
- EventMesh.publish("send_trans_end_flag_to_iot")#退出翻译
- self.trans_flag=0
+ if self.trans_flag == 1: #还是为1就提示已退出AI翻译模式
EventMesh.publish("stop_voice_record") #关闭语音录音
exit_tts ="已退出AI翻译模式"
EventMesh.publish("play_tts",[exit_tts,1])
+ self.trans_flag=0
+ EventMesh.publish("send_trans_end_flag_to_iot")#退出翻译
pass
def exit_voice_message_mode(self, event=None, msg = None):
if self.voice_flag == 1: #还是为1就提示已退出会议纪要模式
battery = EventMesh.publish("get_battery")
print("电量查询:{}".format(battery))
tts_play_str = "电量剩余百分之{}".format(battery)
- EventMesh.publish("play_tts",[tts_play_str,0])
+ EventMesh.publish("play_tts",[tts_play_str,1])
# print("电量!!!!!!!!!!!")
elif "信号" in msg:
signal = net.csqQueryPoll()
tts_play_str = "当前信号{}".format(signal)
- EventMesh.publish("play_tts",[tts_play_str,0])
+ EventMesh.publish("play_tts",[tts_play_str,1])
# print("信号!!!!!!!!!!!")
elif "卡号" in msg:
# print("卡号!!!!!!!!!!!")
tts_play_str = "当前卡号为:{}".format(iccid)
else:
tts_play_str = "卡号查询失败"
- EventMesh.publish("play_tts",[tts_play_str,0])
+ EventMesh.publish("play_tts",[tts_play_str,1])
#改变音色判断
def change_voice(self,event ,msg):
voice = msg
chinese = ''
# 逐位转换,拼接单位
for char in num_str:
- digit = num_map[char]
- chinese += digit
+ if char in num_map:
+ digit = num_map[char]
+ chinese += digit
+ else:
+ chinese += char
return chinese
EventMesh.publish("change_volume",volume)
tts_play_str = "音量已经改为" + find
EventMesh.publish("play_tts",[tts_play_str,0])
+ elif "查看历史留言" in cmd :#当指令中有查看历史留言时,调用历史留言接口
+ pass
#NLP指令
class IOTWeb_Nlp_ConfigProtoCol(ProtoCol):
def recv(self, event, msg):
"""
- @param event:上行下发push_music
+ @param event:上行下发translate_app_enter
@param msg: 接收到的下行数据
"""
- EventMesh.publish("come_trans_mode")#进入AI翻译纪要
+ EventMesh.publish("come_trans_mode")#进入AI翻译
print("recv tts_audio_url{}".format(msg))
+#接收小程序控制进入会议
+class IOTWeb_appcontrol_meetProtoCol(ProtoCol):
+ """meet_control"""
+ TYPE = "meet_control"
+ def send(self, event, msg):
+ # print("translate_app_enter{}".format(msg))
+ # 通过websocket发送到服务器端
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ come_trans = {
+ "msg": "开始会议",
+ "data": None,
+ "cmd": "meet_begin",
+ "ts": 1761121597
+ }
+ 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:上行下发meeting_app_enter
+ @param msg: 接收到的下行数据
+ """
+ data = msg["data"]#判断是开启还是关闭
+ if data == "begin":
+ EventMesh.publish("come_meet_mode")#进入会议纪要
+ elif data == "end":
+ EventMesh.publish("exit_meet_mode")#退出会议纪要
+ print("APP Meeting Control")
+
#翻译播放TTS
class IOTWeb_play_trans_TTSProtoCol(ProtoCol):
"""tts_audio_url"""
@param event:new_voice_msg_list
@param msg: 接收到的下行数据
"""
- new_voice_list = []
+ new_voice = ""
if "data" in msg:
data = msg["data"]
+ print("data = {},data_type = {}".format(data,type(data)))
for da in data:
- new_voice_list.append(da)
-
- if len(new_voice_list) > 0:
+ new_voice = da
+ print("new_voice = {},new_voice_type = {}".format(new_voice,type(new_voice)))
+ if len(new_voice) > 0:
pass
- EventMesh.publish("set_play_new_voice_list",new_voice_list)
+ EventMesh.publish("set_play_new_voice_list",new_voice)
EventMesh.publish("play_new_voice_list")
EventMesh.publish(WEB_CMD_ENUM.NEW_VOICE_MSG_LIST_S)