[bug] board
This commit is contained in:
parent
c6931b1f9f
commit
ab3c47c615
|
@ -210,6 +210,7 @@ class WebSocketClinet:
|
||||||
is_end = False
|
is_end = False
|
||||||
frames = []
|
frames = []
|
||||||
# status buffer
|
# status buffer
|
||||||
|
single_chat_finish = False
|
||||||
slience_bgn_t = time.time()
|
slience_bgn_t = time.time()
|
||||||
slience_time = 0
|
slience_time = 0
|
||||||
print("Start recording...")
|
print("Start recording...")
|
||||||
|
@ -242,6 +243,9 @@ class WebSocketClinet:
|
||||||
|
|
||||||
# 短时沉默结束单次对话:沉默时间超过一定时间段(0.5s左右),则发送数据
|
# 短时沉默结束单次对话:沉默时间超过一定时间段(0.5s左右),则发送数据
|
||||||
if slience_time > recorder.min_act_time:
|
if slience_time > recorder.min_act_time:
|
||||||
|
single_chat_finish = True
|
||||||
|
|
||||||
|
if single_chat_finish:
|
||||||
is_end = True
|
is_end = True
|
||||||
is_bgn = False
|
is_bgn = False
|
||||||
|
|
||||||
|
@ -261,9 +265,11 @@ class WebSocketClinet:
|
||||||
if stream_reset_status:
|
if stream_reset_status:
|
||||||
frames.clear()
|
frames.clear()
|
||||||
is_bgn = False
|
is_bgn = False
|
||||||
|
if single_chat_finish:
|
||||||
|
is_bgn = True
|
||||||
|
is_end = False
|
||||||
|
single_chat_finish = False
|
||||||
|
|
||||||
# print(f"Tatal frames: {_total_frames*record_chunk_size}, valid frame: {_frames*record_chunk_size}, valid RATE: {_frames/_total_frames*100:.2f}%, {_frames*record_chunk_size/recorder.RATE} sec.")
|
|
||||||
# print("End recording.")
|
|
||||||
if board == 'orangepi':
|
if board == 'orangepi':
|
||||||
recorder.hardware.set_led_off("blue")
|
recorder.hardware.set_led_off("blue")
|
||||||
elif self.speaking_event.is_set():
|
elif self.speaking_event.is_set():
|
||||||
|
@ -330,20 +336,21 @@ class WebSocketClinet:
|
||||||
|
|
||||||
# 发送数据
|
# 发送数据
|
||||||
for queue_data in QueueIterator(self.client_queue):
|
for queue_data in QueueIterator(self.client_queue):
|
||||||
|
|
||||||
# 当唤醒状态被关闭时,退出循环
|
|
||||||
if not self.wakeup_event.is_set():
|
|
||||||
self.listening_event.clear()
|
|
||||||
self.speaking_event.clear()
|
|
||||||
client.close_client()
|
|
||||||
break
|
|
||||||
|
|
||||||
# 播放时不得发送数据,默认废消息
|
|
||||||
if self.speaking_event.is_set() and not self.listening_event.is_set():
|
|
||||||
break
|
|
||||||
|
|
||||||
# 发送音频数据
|
# 发送音频数据
|
||||||
if queue_data[0] == 'audio':
|
if queue_data[0] == 'audio':
|
||||||
|
|
||||||
|
# 当唤醒状态被关闭时,退出循环
|
||||||
|
if not self.wakeup_event.is_set():
|
||||||
|
self.listening_event.clear()
|
||||||
|
self.speaking_event.clear()
|
||||||
|
client.close_client()
|
||||||
|
break
|
||||||
|
|
||||||
|
# 播放时不得发送数据,默认废消息
|
||||||
|
if self.speaking_event.is_set() and not self.listening_event.is_set():
|
||||||
|
client.close_client()
|
||||||
|
break
|
||||||
|
|
||||||
audio_dict = queue_data[1]
|
audio_dict = queue_data[1]
|
||||||
|
|
||||||
client.send_per_data(
|
client.send_per_data(
|
||||||
|
@ -353,6 +360,10 @@ class WebSocketClinet:
|
||||||
is_end=audio_dict['is_end'],
|
is_end=audio_dict['is_end'],
|
||||||
encoding='base64',
|
encoding='base64',
|
||||||
)
|
)
|
||||||
|
# is_end后切换播放模式
|
||||||
|
if audio_dict['is_end']:
|
||||||
|
self.listening_event.clear()
|
||||||
|
self.speaking_event.set()
|
||||||
|
|
||||||
if not self.wakeup_event.is_set():
|
if not self.wakeup_event.is_set():
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue