改为测试服务器,208配合禁用vad打断
authorazao <821478748@qq.com>
Fri, 26 Sep 2025 06:50:00 +0000 (14:50 +0800)
committerazao <821478748@qq.com>
Fri, 26 Sep 2025 06:50:00 +0000 (14:50 +0800)
2.sdk/project/K8/sdk/services/microPython/ports/quectel/core/ai_VC.py

index 8969bd6..40043f2 100644 (file)
@@ -1389,6 +1389,7 @@ class AI_VC(Abstract):
         self.Close_flag =0 #=1时,连续对话播放完音频就退出
         self.AI_alarm = _ai_alarm.AI_alarm()
         self.buffer = bytearray(1024*8) #音频缓存区
+        self.stop_tts = 0#音频是否播放完
         #表情变化状态以及检索词
         self.face_status = 0 # 0为正常,1为哭泣,2为愤怒,3为疑惑
         self.normal_list = ["别生气"]
@@ -1425,10 +1426,10 @@ class AI_VC(Abstract):
                 #self.server_ip="sevenpin.qipai.com.cn"
                 self.server_ip="118.145.158.207:22082"
             if dev_type == 'jswm' or dev_type == 'jswm_BOX':# 
-                # self.server_ip="115.190.94.208:22080"
+                self.server_ip="115.190.94.208:22080"
                 # self.server_ip="118.145.158.207:22086"
                 # self.server_ip="118.145.158.207:22080"   
-                self.server_ip="amp.raisound.com"
+                # self.server_ip="amp.raisound.com"
             elif dev_type == "7PIN" or dev_type == "7PIN_coze":
                 #self.server_ip="sevenpin.qipai.com.cn"
                 # self.server_ip="220.160.104.34"
@@ -3159,6 +3160,9 @@ class AI_VC(Abstract):
                             #EventMesh.publish("open_led_green")#绿色
                             self.LocalRespondingEnded_timerout = 3
                             self.VC_state = VC_State_End
+                            if self.stop_tts == 1:
+                                self.AI_client_VC_end_tts()#音频结束
+                                self.stop_tts = 0
                             EventMesh.publish("send_device_VC_state")#上传VC状态
                             pass
                         elif jsload_data["event"] == "command" :#命令匹配
@@ -4039,6 +4043,7 @@ class AI_VC(Abstract):
                     try:
                         self.play_pcm.stream_stop()
                         self.play_pcm.close()
+                        self.stop_tts = 1 
                     except Exception as e:
                         usys.print_exception(e)
                     self.play_pcm=None
@@ -4050,6 +4055,7 @@ class AI_VC(Abstract):
         if self.AI_audio_queue.empty()!=True:
             self.AI_audio_queue.clear()
         
+        
 
     def _1S_timer_cb(self,*argc):
         EventMesh.publish("publish_AI_btnInfo",{"func":self._1S_timer_cb_}) 
@@ -4180,75 +4186,6 @@ class AI_VC(Abstract):
             voice = self.VC_TTS_voice_type[self.VC_TTS_voice_key]["voice"]
         except Exception as e:
             usys.print_exception(e)    
-        #voice="zh_female_dongmanxiaoyang_moon_bigtts"
-        # #海外服务器
-        # json_data = \
-        # {
-        #     "event": "start",
-        #     "payload": {
-        #         "simple_response": False,
-        #         "device_id": modem.getDevImei(),
-        #         "user_agent": "AudioClientWithAEC/1.0",
-        #         "dialog_attributes": {
-        #             "provider": "openai",
-        #             "cfg": {
-        #                 "disable_empty_prompt": True,
-        #                 "greeting":{
-        #                     "enabled": True,
-        #                     "content": "Hi! What can I do for you.",
-        #                 },
-        #                 "openai_option": {
-        #                     "model": "gpt-4o",
-        #                     "system": {
-        #                         "type": "file",
-        #                         "content": "1567d9e19ac09269d8ce6c887494ff01" # 林悦
-        #                     },
-        #                 }
-        #             }
-        #         },
-        #         "outbound_attributes": {
-        #             "provider": "azure",
-        #             "cfg": {
-        #                 "format": "pcm",
-        #                 "sample_rate": 16000,
-        #                 "bit_rate": 16,
-        #                 "channel": 1,
-        #                 "volume": 100,
-        #                 # "voice": "en-US-AvaMultilingualNeural", #"cosyvoice-v2-amp-2f7d423",# "longjielidou",
-        #                 "voice":"zh-CN-XiaoxiaoNeural",# mandarin
-        #                 "speech_rate": 0,
-        #                 "chunk_interval_ms": 10
-        #             }
-        #         },
-        #         "inbound_attributes": {
-        #             "provider": "azure",
-        #             "disable_vad": False,
-        #             "vad_silence": 200,
-        #             "interrupt_options": {
-        #                 "concatenate_results": True,
-        #                 "thinking_time_only": True,
-        #                 # "keyword_interrupt": True,
-        #                 # "interrupt_keywords": ["停止", "打断","打断一下", "等一下", "别说了", "打住"]
-        #             },
-        #             "cfg": {
-        #                 "format": "pcm",
-        #                 "sample_rate": 16000,
-        #                 "bit_rate": 16,
-        #                 "channel": 1,
-        #                 "enable_punctuation": True,
-        #                 "enable_itn": True,
-        #                 "keywords": [
-        #                     "停止",
-        #                     "打断",
-        #                     "打断一下",
-        #                     "等一下",
-        #                     "别说了",
-        #                     "打住"
-        #                 ]
-        #             }
-        #         }
-        #     }
-        # }
         json_data = \
         {
             "header": {
@@ -4307,6 +4244,8 @@ class AI_VC(Abstract):
                     "interrupt_options":{
                         "concatenate_results":True,
                         "thinking_time_only": True,
+                        "keyword_interrupt": True,
+                        "interrupt_keywords": ["停止","打断"]
                     },
                     "cfg": {
                         "format": "pcm",
@@ -4447,7 +4386,15 @@ class AI_VC(Abstract):
         self.AI_client_VC_send(ujson.dumps(json_data))
         EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})
 
-  
+    #tts本地播放结束
+    def AI_client_VC_end_tts(self):
+        json_data = \
+        {  
+            "event": "audio.played",
+            "payload": {}
+        }
+        self.AI_client_VC_send(ujson.dumps(json_data))
+        print("tts结束")
     #客户端打断对话
     def AI_client_VC_RequestToSpeak(self):
         json_data = \