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 = ["别生气"]
#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"
#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" :#命令匹配
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
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_})
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": {
"interrupt_options":{
"concatenate_results":True,
"thinking_time_only": True,
+ "keyword_interrupt": True,
+ "interrupt_keywords": ["停止","打断"]
},
"cfg": {
"format": "pcm",
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 = \