[button] fix bugs

This commit is contained in:
IrvingGao 2024-06-18 22:18:31 +08:00
parent 70b3cc9a62
commit cc5009f368
1 changed files with 17 additions and 8 deletions

View File

@ -366,6 +366,7 @@ class WebSocketClinet:
audio_dict = queue_data[1] audio_dict = queue_data[1]
try:
client.send_per_data( client.send_per_data(
audio=audio_dict['frames'], audio=audio_dict['frames'],
stream=True, stream=True,
@ -373,6 +374,10 @@ class WebSocketClinet:
is_end=audio_dict['is_end'], is_end=audio_dict['is_end'],
encoding='base64', encoding='base64',
) )
except BrokenPipeError:
print(f"{datetime.now()}: web socket connection broken, skip send data.")
client.close_client()
break
# is_end后切换播放模式 # is_end后切换播放模式
if audio_dict['is_end']: if audio_dict['is_end']:
self.listening_event.clear() self.listening_event.clear()
@ -381,6 +386,10 @@ class WebSocketClinet:
if not self.wakeup_event.is_set(): if not self.wakeup_event.is_set():
continue continue
if self.listening_event.is_set():
print(f"{datetime.now()}: listening, skip setup web socket connection.")
continue
# 接收数据 # 接收数据
while True: while True:
# 当唤醒状态被关闭时,退出循环 # 当唤醒状态被关闭时,退出循环