备份
authorp15692025051 <846603105@qq.com>
Thu, 13 Mar 2025 06:42:38 +0000 (14:42 +0800)
committerp15692025051 <846603105@qq.com>
Thu, 13 Mar 2025 06:42:38 +0000 (14:42 +0800)
2.sdk/project/7PIN/sdk/services/microPython/ports/quectel/core/ai_VC.py

index 818179f..4fec50d 100644 (file)
@@ -32,9 +32,12 @@ import constants
 import versions
 
 #dev_type = "G10"
-#dev_type = "7PIN_BK"
-dev_type = "7PIN"
-
+dev_type = "7PIN_BK"#小瑞
+#dev_type = "7PIN"#柒牌
+#dev_type = 'momo'#食梦貘
+#dev_type = 'sjgq'#四季甘泉
+#dev_type = 'szbst'#深圳百事通
+#dev_type = 'rabbit'
 class AI_led(Abstract):
     def __init__(self):
         if dev_type == "G10":
@@ -165,7 +168,7 @@ class AI_led(Abstract):
         self.led_blue.write(0)
         self.led_green.write(0)
 
-audio_buf = ['didianguanji', 'IMEIhao', 'jianquancuowu', 'key_prompt', 'liuliangtishi', 'Low_power_warning', 'R_CHARGE_FULL', 'R_CHARGE_IN', 'R_CHARGE_OUT', 'R_READ_TIME_0', 'R_READ_TIME_1', 'R_READ_TIME_2', 'R_READ_TIME_3', 'R_READ_TIME_4', 'R_READ_TIME_5', 'R_READ_TIME_6', 'R_READ_TIME_7', 'R_READ_TIME_8', 'R_READ_TIME_9', 'R_READ_TIME_A', 'R_READ_TIME_B', 'R_READ_TIME_C', 'R_READ_TIME_D', 'R_READ_TIME_E', 'R_READ_TIME_F', 'R_READ_TIME_G', 'R_READ_TIME_H', 'R_READ_TIME_I', 'R_READ_TIME_J', 'R_READ_TIME_K', 'R_READ_TIME_L', 'R_READ_TIME_M', 'R_READ_TIME_N', 'R_READ_TIME_O', 'R_READ_TIME_P', 'R_READ_TIME_Q', 'R_READ_TIME_R', 'R_READ_TIME_S', 'R_READ_TIME_T', 'R_READ_TIME_U', 'R_READ_TIME_V', 'R_READ_TIME_W', 'R_READ_TIME_X', 'R_READ_TIME_Y', 'R_READ_TIME_Z', 'shouhou', 'xinhaoruo1', 'zhengzaiguanji']
+audio_buf = ['chenggong', 'didianguanji', 'IMEIhao', 'jianquancuowu', 'key_prompt', 'liuliangtishi', 'Low_power_warning', 'R_CHARGE_FULL', 'R_CHARGE_IN', 'R_CHARGE_OUT', 'R_READ_TIME_0', 'R_READ_TIME_1', 'R_READ_TIME_2', 'R_READ_TIME_3', 'R_READ_TIME_4', 'R_READ_TIME_5', 'R_READ_TIME_6', 'R_READ_TIME_7', 'R_READ_TIME_8', 'R_READ_TIME_9', 'R_READ_TIME_A', 'R_READ_TIME_B', 'R_READ_TIME_C', 'R_READ_TIME_D', 'R_READ_TIME_E', 'R_READ_TIME_F', 'R_READ_TIME_G', 'R_READ_TIME_H', 'R_READ_TIME_I', 'R_READ_TIME_J', 'R_READ_TIME_K', 'R_READ_TIME_L', 'R_READ_TIME_M', 'R_READ_TIME_N', 'R_READ_TIME_O', 'R_READ_TIME_P', 'R_READ_TIME_Q', 'R_READ_TIME_R', 'R_READ_TIME_S', 'R_READ_TIME_T', 'R_READ_TIME_U', 'R_READ_TIME_V', 'R_READ_TIME_W', 'R_READ_TIME_X', 'R_READ_TIME_Y', 'R_READ_TIME_Z', 'send_tone', 'shouhou', 'xinhaoruo1', 'zhengzaiguanji']
 class AI_dev(Abstract):
     # AI
     def __init__(self):
@@ -356,7 +359,10 @@ class AI_dev(Abstract):
                         #EventMesh.publish("publish_AI_btnInfo",{"func":self.pwk_key_Long_Press})  
             if self.pwk_key_status == 1:#松开
                 #print("pwk_key_timer_cb:{}".format(self.pwk_key_timer_count))
-                if self.pwk_key_timer_count >= 5: #防抖200ms
+                key_count = 5
+                if dev_type == "7PIN_BK":
+                    key_count = 3
+                if self.pwk_key_timer_count >= key_count: #防抖200ms
                     #EventMesh.publish("AI_key_release")
                     EventMesh.publish("publish_AI_btnInfo",{"func":self.pwk_key_release})
                     self.pwk_key.enable()
@@ -385,7 +391,8 @@ class AI_dev(Abstract):
                     self.KeyAI_timer.start(100, 1, self.KeyAI_timer_cb)
                     self.KeyAI_timer_count = 0
                     #EventMesh.publish("AI_key_press")
-                    self.aud.aud_tone_play(10,200)#播放按键音
+                    if dev_type == "7PIN" :
+                        self.aud.aud_tone_play(10,200)#播放按键音
                     EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_key_press})  
         except Exception as e: 
             usys.print_exception(e)
@@ -402,7 +409,10 @@ class AI_dev(Abstract):
                         EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_key_long_press})  
             if self.KeyAI_status == 1:#松开
                 #print("KeyAI_timer_cb:{}".format(self.KeyAI_timer_count))
-                if self.KeyAI_timer_count >= 5: #防抖200ms
+                key_count = 5
+                if dev_type == "7PIN_BK":
+                    key_count = 3
+                if self.KeyAI_timer_count >= key_count: #防抖200ms
                     #EventMesh.publish("AI_key_release")
                     EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_key_release})  
                     self.extint_AI.enable()
@@ -510,6 +520,7 @@ class AI_dev(Abstract):
             return 10
     def audio_montage_play(self,event,msg):
         self.aud.stopPlayStream()
+        self.aud.stopAll()
         str_data='mp3files='
         for i in msg:
             try:
@@ -1151,6 +1162,7 @@ class AI_VC(Abstract):
         self.record_fd = None
         self.play_fd = None
         self.is_VC_ACK = 0 #是否开启ack应答模式
+        self.is_long_record = 0 #是否开启长录音模式(语音打断模式)
         self.ai_OTA = OTA()
         self.is_auth = 0 #是否开启dmp鉴权
         #self.VC_mode = 0 #0:短按连续问答模式 1:长按录音模式
@@ -1161,7 +1173,7 @@ class AI_VC(Abstract):
         self.error_data = []
         self.asr_taskid  = ""
         self.VC_taskid  = ""
-        self.VC_server = 0 #0柒牌正式服务器,1:测试服务器1,2:测试服务器2
+        self.VC_server = 86 #0柒牌正式服务器,1:测试服务器1,2:测试服务器2
 
         self.server_ip = EventMesh.publish("get_storage_config","server_ip")#
         if self.server_ip == None:
@@ -1169,17 +1181,47 @@ class AI_VC(Abstract):
                 self.server_ip="118.145.158.207:22083"
             elif self.VC_server == 2:# 
                 self.server_ip="118.145.158.207:22082"
+            elif self.VC_server == 4:# 
+                self.server_ip="118.145.158.207:22084"
+            elif self.VC_server == 5:# 
+                self.server_ip="amp-wss.raisound.com"
+            elif self.VC_server == 6:# 
+                self.server_ip="118.145.158.207:22080"
+            elif self.VC_server == 86:# 
+                self.server_ip="118.145.158.207:22086"
             else:
+                #self.server_ip="sevenpin.qipai.com.cn"
+                self.server_ip="118.145.158.207:22082"
+            if dev_type == 'momo':# 
+                self.server_ip="118.145.158.207:22080"
+            elif dev_type == "7PIN":
                 self.server_ip="sevenpin.qipai.com.cn"
+
+            elif dev_type == "sjgq":
+                self.server_ip="118.145.158.207:22084"
+            elif dev_type == "szbst" or dev_type == 'rabbit':
+                self.server_ip="118.145.158.207:22086"
+                #self.server_ip="115.190.94.208:22080"
         #开机提示音
         self.power_on_tone = EventMesh.publish("get_storage_config","power_on_tone")#
+        if dev_type != "7PIN":
+            self.power_on_tone = None
         if self.power_on_tone == None:
             if dev_type == "G10":
                 self.power_on_tone = "已开机,您好!我是北科瑞讯智能 AI bot_name"
             elif dev_type == "7PIN_BK":
-                self.power_on_tone = "小瑞祝大家新年快乐!我们一起来愉快地聊天吧!" 
+                self.power_on_tone = "小瑞来了!我们一起来愉快地聊天吧!" 
+            elif dev_type == 'rabbit':
+                self.power_on_tone = "兔兔来了!我们一起来愉快地聊天吧!" 
+            elif dev_type == "szbst":
+                self.power_on_tone = "深圳百事通来了!请问您有什么需要我帮忙的吗?" 
+            
+            elif dev_type == "momo":
+                self.power_on_tone = "DuloDulo,我是上古神兽食梦貘,主人可以叫我momo,我来自《山海经》,是一只以梦为食的神秘灵兽,每当颜色朦胧、人们入睡时,我就会悄悄飞到人们的床头,用我长长的鼻子把噩梦统统吞噬掉,只留下甜甜的美梦。从今往后,就由我守护在主人身边,一起度过每一个星河璀璨的夜晚。"
+            elif dev_type == "sjgq":
+                self.power_on_tone = "您好!我是巴马四季甘泉的智能助手。我可以为你解答各种各样的问题,像是有关巴马四季甘泉知识库、中基长寿科学产品、卫斯曼院士国际先进医疗中心的问题,还有日常生活与工作、旅游信息、健康咨询、教育与学习、情感交流、全球资讯、世界文化等方面的问题哦。你有没有这方面的问题想要问我呀?"
             else:
-                self.power_on_tone = "您好!我是柒牌男装AI生活好帮手-bot_name, 很高兴为您服务,我可以帮您解答柒牌公司知识库、日常生活与工作、旅游信息、健康与运动咨询、教育与学习、情感交流、全球资讯、世界文化等问题!请问您有什么需要我帮忙的吗?" 
+                self.power_on_tone = "您好!我是世界首创柒牌男装AI生活好帮手-bot_name, 很高兴为您服务,我可以帮您解答柒牌公司知识库、日常生活与工作、旅游信息、健康与运动咨询、教育与学习、情感交流、全球资讯、世界文化等问题!请问您有什么需要我帮忙的吗?" 
                 
 
         self.VC_record_TYPE = VC_record_TYPE_PCM #0:PCM 1:AMR
@@ -1189,40 +1231,76 @@ class AI_VC(Abstract):
         
         self.VC_TTS_voice_type = EventMesh.publish("get_storage_config","VC_TTS_voice_type")#音色配置
         if self.VC_TTS_voice_type == None or ("男" in self.VC_TTS_voice_type) == False:
-            if dev_type == "G10" or  dev_type == "7PIN_BK":
+            if dev_type == "G10" or  dev_type == "7PIN_BK"or dev_type == "szbst"or dev_type == 'rabbit':
                 self.VC_TTS_voice_type = {   
                                             "女":{
                                             "bot_name":"小瑞",
-                                            "voice":"zh_female_wanwanxiaohe_moon_bigtts" ,
+                                            "voice":"huoshan::zh_female_wanwanxiaohe_moon_bigtts" ,
                                             "lang":"zh-cn"
                                             },
                                             "男":{
                                             "bot_name":"小瑞",
-                                            "voice":"zh_male_wennuanahu_moon_bigtts"  ,
+                                            "voice":"huoshan::zh_male_wennuanahu_moon_bigtts"  ,
                                             "lang":"zh-cn"
                                             },
                                             "童":{
                                             "bot_name":"小瑞",
-                                            "voice":"ICL_zh_female_huoponvhai_tob"  ,
+                                            "voice":"huoshan::ICL_zh_female_huoponvhai_tob"  ,
                                             "lang":"zh-cn"
                                             },
                                             "粤":{
                                             "bot_name":"小瑞",
-                                            "voice":"zh_female_wanqudashu_moon_bigtts" ,
+                                            "voice":"huoshan::zh_female_wanqudashu_moon_bigtts" ,
                                             "lang":"zh-hk" 
                                             },
                                             "四川":{
                                             "bot_name":"小瑞",
-                                            "voice":"zh_female_daimengchuanmei_moon_bigtts",
+                                            "voice":"huoshan::zh_female_daimengchuanmei_moon_bigtts",
                                             "lang":"&lang=zh-cn-sc"  
                                             },
                                             "个性":{
                                             "bot_name":"小瑞",
-                                            "voice":"zh_male_sunwukong_mars_bigtts" ,
+                                            "voice":"huoshan::zh_male_sunwukong_mars_bigtts" ,
                                             "lang":"zh-cn" 
                                             }
                                            
                                         }
+            elif dev_type == 'momo':
+                self.VC_TTS_voice_type = {   
+                                            "女":{
+                                            "bot_name":"食梦貘",
+                                            "voice":"huoshan::zh_female_shaoergushi_mars_bigtts" ,
+                                            "lang":"zh-cn"
+                                            },
+                                            "男":{
+                                            "bot_name":"食梦貘",
+                                            "voice":"huoshan::zh_male_yangguangqingnian_mars_bigtts"  ,
+                                            "lang":"zh-cn"
+                                            },
+                                            "童":{
+                                            "bot_name":"食梦貘",
+                                            "voice":"huoshan::ICL_zh_female_huoponvhai_tob"  ,
+                                            "lang":"zh-cn"
+                                            },
+                }
+            elif dev_type == 'sjgq':
+                self.VC_TTS_voice_type = {   
+                                            "女":{
+                                            "bot_name":"小巴",
+                                            "voice":"huoshan::zh_female_wanwanxiaohe_moon_bigtts" ,
+                                            "lang":"zh-cn"
+                                            },
+                                            "男":{
+                                            "bot_name":"小巴",
+                                            "voice":"huoshan::zh_male_wennuanahu_moon_bigtts"  ,
+                                            "lang":"zh-cn"
+                                            },
+                                            "童":{
+                                            "bot_name":"小巴",
+                                            "voice":"huoshan::ICL_zh_female_huoponvhai_tob"  ,
+                                            "lang":"zh-cn"
+                                            },
+                }
             else:
                 #女,男,童,粤,川,个性声
                 self.VC_TTS_voice_type = {   
@@ -1271,11 +1349,14 @@ class AI_VC(Abstract):
             
             #EventMesh.publish("set_storage_config",["VC_TTS_voice_type",self.VC_TTS_voice_type])
 
+        
         try:
             self.VC_TTS_voice_key = EventMesh.publish("get_storage_config","VC_TTS_voice_key")#音色配置
             if self.VC_TTS_voice_key == None :
-                if dev_type == "7PIN_BK":
+                if dev_type == "7PIN_BK" or dev_type == 'rabbit':
                     self.VC_TTS_voice_key = "童"
+                elif dev_type == "momo":
+                    self.VC_TTS_voice_key = "男"
                 else:
                     self.VC_TTS_voice_key = "男"
             if self.VC_TTS_voice_key in self.VC_TTS_voice_type:
@@ -1299,7 +1380,7 @@ class AI_VC(Abstract):
         self.AI_ASR_send_data_queue = Queue(200)
         self.AI_VC_send_data_queue = Queue(100)
         self.AI_audio_queue = Queue(100)
-        self.AI_WS_connect_Queue = Queue(100) #释放用
+        #self.AI_WS_connect_Queue = Queue(100) #释放用
         self.AI_TTS_str = ""
         self.AI_ASR_str = ""
         self.AI_ASR_flag = 0
@@ -1589,7 +1670,7 @@ class AI_VC(Abstract):
         self.AI_ASR_text_tmp = ""
         if self.AI_client_asr_isconnect == 1:
             return
-        # 创建VC客户端
+        # 创建ASR客户端
         try:
             signal = net.csqQueryPoll()
             if signal == -1 or sim.getStatus() != 1:#网络正常
@@ -1599,6 +1680,8 @@ class AI_VC(Abstract):
             # self.AI_client_asr = uwebsocket.Client.connect('wss://nls-gateway-cn-beijing.aliyuncs.com/ws/v1',headers=Headers, debug=False)
             req_str = ""
             platform = "platform=huoshan"
+            #platform= "platform=xfyun-ita"
+            platform= "platform=xfyun-bigmodel-ita"
             lang = "lang=zh-cn"#普通话测试环境
             try:
                 if "loang" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]:
@@ -1614,7 +1697,7 @@ class AI_VC(Abstract):
             url = 'ws://{}/{}&dt={}'.format(self.server_ip,req_str,token)
             print("websocket_connect_asr URL:{}".format(url))
             self.AI_client_asr = uwebsocket.Client.connect(url, debug=True)#
-            self.AI_WS_connect_Queue.put(self.AI_client_asr)
+            #self.AI_WS_connect_Queue.put(self.AI_client_asr)
             
         except Exception as e: #网络连接异常
             usys.print_exception(e)
@@ -1884,6 +1967,7 @@ class AI_VC(Abstract):
                                 self.VC_state =  VC_State_SpeechStart
                                 EventMesh.publish("open_led_blue")
                                 self.AI_ASR_error_timeout = 0
+                                
                                 pass
 
                             elif jsload_data["event"] == "Changed" or jsload_data["event"] == "SentenceEnd" : #开始录音Changed
@@ -1895,9 +1979,10 @@ class AI_VC(Abstract):
                                     #self.AI_listen_text = str(jsload_data["result"]["result"])
                                     text= str(jsload_data["result"]["result"])
                                     print("ASR recv self.VC_state :{}".format(self.VC_state))
-                                    if self.VC_state >= VC_State_TTSStart:#开始播音后不响应asr结果
-                                        print("asr continue")
-                                        continue
+                                    if self.is_long_record == 0:
+                                        if self.VC_state >= VC_State_TTSStart:#开始播音后不响应asr结果
+                                            print("asr continue")
+                                            continue
                                     EventMesh.publish("open_led_blue")
                                     
                                     if jsload_data["result"]["is_end"] == True:  #asr结束
@@ -1905,7 +1990,6 @@ class AI_VC(Abstract):
                                         self.AI_ASR_error_timeout = 0
                                         self.AI_ASR_text_repet_count = 0
                                         self.AI_ASR_text_tmp = ""
-                                        self.VC_state =  VC_State_SpeechEnd
                                         self.VC_record_state_flag = 4
                                         ret= self.check_text(text)
                                         if ret == 0:#配置指令
@@ -1937,7 +2021,9 @@ class AI_VC(Abstract):
                                                     self.AI_ASR_str = self.AI_ASR_str_tmp+text
                                                     print("ASR ASR 打断 续集 AI_ASR_str {}".format(self.AI_ASR_str))
                                                     self.AI_ASR_str_tmp = self.AI_ASR_str
-                                                    #EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_deconnect_VC})#关闭vc连接
+                                                    if self.is_long_record != 0:
+                                                        #if self.VC_state >= VC_State_TTSStart:#如果已经播放了,关闭VC连接,重新打开,处理音频数据太多问题
+                                                        EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_deconnect_VC})#关闭vc连接
                                                 self.AI_ASR_flag  = 1
                                                 print("asr recv :asr_str:{}".format(self.AI_ASR_str))  
                                                 #EventMesh.publish("publish_AI_btnInfo",{"func":utime.sleep_ms,"data":(500)}) #等一秒
@@ -1950,7 +2036,7 @@ class AI_VC(Abstract):
                                                     print("asr recv :asr_str:{}".format(self.AI_ASR_str))  
                                                     #EventMesh.publish("publish_AI_btnInfo",{"func":utime.sleep_ms,"data":(500)}) #等一秒
                                                     EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start}) 
-                                            
+                                        self.VC_state =  VC_State_SpeechEnd
                                     elif jsload_data["result"]["is_end"] == False:
                                         
                                         self.VC_state =  VC_State_SpeechIng
@@ -1972,7 +2058,9 @@ class AI_VC(Abstract):
                                                 self.AI_ASR_flag = 2
                                                 print("asr 打断,关闭VC连接")
                                                 self.AI_ASR_str = ""
-                                                # EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_deconnect_VC})#关闭vc连接
+                                                if self.is_long_record != 0:
+                                                    self.VC_Play_End()
+                                                    EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_deconnect_VC})#关闭vc连接
                                                 # EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_connect_VC})#连接服务器
                                                 # EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_VC_start_requset})#请求
                                                 EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start}) 
@@ -2042,12 +2130,15 @@ class AI_VC(Abstract):
      #开始录音
     def VC_Speech_Start(self):
         try:
+            
             #self.VC_state =  VC_State_SpeechStart
             print("VC_Speech_Start VC_record_state_flag:{} self.AI_ASR_flag:{}!!!!!!!!".format(self.VC_record_state_flag,self.AI_ASR_flag))  
             if self.AI_ASR_flag  != 0:
                 return
+            
             if self.VC_record_state_flag  == 0:
-                
+                if dev_type != "7PIN" :
+                    EventMesh.publish("publish_AI_btnInfo",{"func":self.chenggong_tone}) 
                 self.websocket_connect_asr()   
                 self.VC_record_thread_close()#关闭录音线程
                 _thread.stack_size(self.Audio_buf_size+8*1024)
@@ -2055,6 +2146,7 @@ class AI_VC(Abstract):
                 _thread.stack_size(8*1024)
                 print("self.VC_record_thread_id:{}".format(self.VC_record_thread_id))
                 try:
+                    
                     if self.VC_record_TYPE == VC_record_TYPE_AMR :
                         try :
                             self.record.stream_start(audio.Record.AMRNB, self.VC_record_samplerate, 0)
@@ -2269,8 +2361,22 @@ class AI_VC(Abstract):
                 platform = "platform=huoshan&is_boot=1"
                 #platform = "platform=raisound"
                 #platform = "platform=aliyun"
+            elif dev_type == "7PIN_BK" :
+                platform = "platform=huoshan"
+                #platform = "platform=raisound&bot_type=dify"   
+                #platform = "platform=raisound&bot_type=fourseason_water"
+                #platform = "platform=raisound&bot_type=szbst"
                 
-
+                pass
+            elif dev_type == "szbst":
+                platform = "platform=raisound&bot_type=szbst"
+            elif  dev_type == 'rabbit':
+                platform = "platform=raisound&bot_type=rabbit"
+            elif dev_type == 'momo':# 
+                #22080/voice-chat/v2.1/ws?platform=raisound&bot_type=deepseek
+                platform = "platform=raisound&bot_type=shimeng_mo"
+            elif dev_type == "sjgq":
+                platform = "platform=raisound"
             else:
                 platform = "platform=huoshan"
                 #platform = "platform=huoshan&is_boot=1"
@@ -2288,35 +2394,21 @@ class AI_VC(Abstract):
             # self.AI_client_VC = uwebsocket.Client.connect('wss://nls-gateway-cn-beijing.aliyuncs.com/ws/v1',headers=Headers, debug=False)
             token = EventMesh.publish("get_dev_token")
             print("token:{}".format(token))
-            req_str = "voice-chat/ws?is_auth={}&{}&{}".format(self.is_auth,platform,lang)
+            if dev_type == 'momo' :# 
+                req_str = "voice-chat/v2.1/ws?is_auth={}&{}&{}".format(self.is_auth,platform,lang)
+            elif dev_type == '7PIN_BK'or dev_type == "szbst" or dev_type == 'rabbit':
+                req_str = "voice-chat/v2.1/ws?is_auth={}&{}&{}".format(self.is_auth,platform,lang)
+                #req_str = "voice-chat/ws?is_auth={}&{}&{}".format(self.is_auth,platform,lang)
+            elif dev_type == "sjgq":
+                req_str = "22085/voice-chat/ws?is_auth={}&{}&{}".format(self.is_auth,platform,lang)
+            else:
+                req_str = "voice-chat/ws?is_auth={}&{}&{}".format(self.is_auth,platform,lang)
             url = 'ws://{}/{}&dt={}'.format(self.server_ip,req_str,token)
             print("VC VC:url{}".format(url))
             self.AI_client_VC = uwebsocket.Client.connect(url, debug=True)
-            self.AI_WS_connect_Queue.put(self.AI_client_VC)
-            # if self.VC_server == 1:# 
-            #     #柒牌服务器地址sevenpin.qipai.com.cn
-            #     #北科服务器118.145.158.207:22082
-            #     self.AI_client_VC = uwebsocket.Client.connect('ws://118.145.158.207:22082/voice-chat/ws', debug=False)#测试环境
-            # elif self.VC_server == 2:# 
-            #     token = EventMesh.publish("get_dev_token")
-            #     print("token:{}".format(token))
-            #     req_str = "/voice-chat/ws?is_auth=0&{}&{}".format(platform,lang)
-            #     url = 'ws://118.145.158.207:22082{}&dt={}'.format(req_str,token)
-            #     print("VC VC:url{}".format(url))
-            #     self.AI_client_VC = uwebsocket.Client.connect(url, debug=True)
-                
-            # else:
-            #     req_str = "is_auth=0&{}&{}".format(platform,lang)
-            #     print("req_str2:{}".format(req_str))
-            #     token = EventMesh.publish("get_dev_token")
-            #     print("token:{}".format(token))
-            #     url = 'ws://sevenpin.qipai.com.cn/voice-chat/ws?{}&dt={}'.format(req_str,token)
-            #     print("VC VC:url{}".format(url))
-            #     if token != None:
-            #         self.AI_client_VC = uwebsocket.Client.connect(url, debug=False)
-            #     else:
-            #         self.websocket_error()
-            #         return
+            #self.AI_WS_connect_Queue.put(self.AI_client_VC)
+
+       
             print("websocket_connect_VC:OK!!!!!!!!!!!!!!!!!!!!!")
         except Exception as e: #网络连接异常
             usys.print_exception(e)
@@ -2644,7 +2736,11 @@ class AI_VC(Abstract):
                         elif jsload_data["event"]  == "RespondingStarted" :#音频开始下发
                             self.play_flag = 0
                             self.VC_state = VC_State_TTSStart
-                            EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})#调试临时关闭
+                            if self.is_long_record == 0:
+                                EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})#
+                            else:
+                                self.AI_ASR_str_tmp = ""
+                                self.AI_ASR_str = ""
                             EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Play_Start})
                             self.VC_Thinking_timerout = 0#关闭超时重试
                             # self.VC_Play_Start()
@@ -2660,12 +2756,14 @@ class AI_VC(Abstract):
                             pass
                         elif jsload_data["event"]  == "RespondingEnded" :#音频下发结束
                             #if self.VC_state == VC_State_TTSStart:
+                            
                             print("RespondingEnded!!!!!!" )
                             self.VC_state = VC_State_TTSEnd
                             self.LocalRespondingEnded_timerout = 10 #最长倒数10秒发送音频结束或者终止对话
                             if self.VC_mode == 0 :#连续问答模式
                                 #EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})#调试临时打开
-                                EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_Start})#开始录音 
+                                if dev_type != "7PIN_BK":
+                                    EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_Start})#开始录音 
                                 pass
                             if self.play_data_save_flag == 1:
                                 if self.play_fd !=None:
@@ -2679,8 +2777,10 @@ class AI_VC(Abstract):
                                 if self.AI_TTS_str != "" or self.AI_ASR_str != "":#有tts数据,则请求TTS数据,没有就请求开始上传语音
                                     self.AI_client_VC_RequestToRespond()
                                 else:
+                                    pass
                                     #self.VC_Speech_Start()#开启线程获取录音数据
-                                    EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_Start})#
+                                    if self.is_long_record == 0:
+                                        EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_Start})#
                                     #self.AI_client_VC_send_speech()#开始上传语音
                                 
                                 #EventMesh.publish("open_led_red")
@@ -2899,7 +2999,6 @@ class AI_VC(Abstract):
                         self.AI_TTS_str ="服务器地址"+self.server_ip
                         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 = "有新版本,准备开始升级,升级过程会多次重启设备,请保证流量充足及电量充足"
                     else:
@@ -2912,6 +3011,7 @@ class AI_VC(Abstract):
         except Exception as e:
                 usys.print_exception(e)
         return -1
+
     #获取trace_id
     def get_trace_id(self):
         t = utime.mktime(utime.localtime())
@@ -2951,17 +3051,22 @@ class AI_VC(Abstract):
     def VC_Play_Start(self):
         self.tts_in_data_len = 0
         self.tts_out_data_len = 0
-        if self.VC_play_TYPE == VC_play_TYPE_PCM:
-            if self.VC_play_samplerate == 8000:
+        try:
+            if self.VC_play_TYPE == VC_play_TYPE_PCM:
+                if self.VC_play_samplerate == 8000:
+                    pass
+                elif self.VC_play_samplerate == 16000:
+                    if self.play_pcm == None:        
+                        self.play_pcm = audio.Audio.PCM(0,1,16000,1,1,2)
+                        #self.play_pcm.setVolume(11)
+                        ret = self.play_pcm.stream_write_start()
+                        print("self.record_pcm.stream_write_start:ret:{}".format(ret))
+            elif self.VC_play_TYPE == VC_play_TYPE_MP3:
                 pass
-            elif self.VC_play_samplerate == 16000:
-                if self.play_pcm == None:        
-                    self.play_pcm = audio.Audio.PCM(0,1,16000,1,1,2)
-                    #self.play_pcm.setVolume(11)
-                    ret = self.play_pcm.stream_write_start()
-                    print("self.record_pcm.stream_write_start:ret:{}".format(ret))
-        elif self.VC_play_TYPE == VC_play_TYPE_MP3:
-            pass
+        except Exception as e:
+            
+            usys.print_exception(e)
+            EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_error,"data":"接口出错了。请重试"}) 
     #停止播放声音
     def VC_Play_End(self):
         if self.VC_play_TYPE == VC_play_TYPE_PCM:
@@ -3126,7 +3231,7 @@ class AI_VC(Abstract):
                 "session_id": self.session_id ,
                 "custom_variables":{
                     "bot_name":"{}".format(self.bot_name)
-                    }
+                    },
                 },
             
         }
@@ -3267,8 +3372,15 @@ class AI_VC(Abstract):
             json_data["payload"]["type"] = "prompt"
             EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_init}) 
             EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_VC_send,"data":ujson.dumps(json_data)})
+            if dev_type != "7PIN" :
+                EventMesh.publish("publish_AI_btnInfo",{"func":self.send_tone}) 
+            #
             #self.AI_ASR_str = ""
         # utime.sleep_ms(1)
+    def chenggong_tone(self):
+        EventMesh.publish("audio_montage_play",["chenggong.mp3"])    
+    def send_tone(self):
+        EventMesh.publish("audio_montage_play",["send_tone.mp3"])
     #给服务器回应ack
     def AI_client_VC_Read(self):
         json_data = \
@@ -3330,12 +3442,8 @@ class AI_VC(Abstract):
                     
                     
                 else:
-                    
-                    
                     self.AI_audio_queue_thread_lock = 1
                     data = self.AI_audio_queue.get()
-                    
-                    
                     self.close_timerout = 0
                     if self.play_flag == 0:
                         self.play_flag =1
@@ -3472,22 +3580,22 @@ class AI_VC(Abstract):
         self.AI_ASR_send_buf_len = 0
         #self.AI_WS_connect_Queue.put(self.AI_client_VC)
 
-        try:
-            while True:
-                if self.AI_WS_connect_Queue.empty()!=True:
-                    AI_WS_connect = self.AI_WS_connect_Queue.get()
-                    if AI_WS_connect :
-                        try:
-                            AI_WS_connect._close()
-                            AI_WS_connect = None
-                        except Exception as e:
-                            usys.print_exception(e)
-                    else:
-                        print("websocket链接已为空")
-                else:
-                    break
-        except Exception as e:
-            usys.print_exception(e)
+        # try:
+        #     while True:
+        #         if self.AI_WS_connect_Queue.empty()!=True:
+        #             AI_WS_connect = self.AI_WS_connect_Queue.get()
+        #             if AI_WS_connect :
+        #                 try:
+        #                     AI_WS_connect._close()
+        #                     AI_WS_connect = None
+        #                 except Exception as e:
+        #                     usys.print_exception(e)
+        #             else:
+        #                 print("websocket链接已为空")
+        #         else:
+        #             break
+        # except Exception as e:
+        #     usys.print_exception(e)
 
     def VC_init2(self):
         self.VC_init()