[bug] board
This commit is contained in:
1 parent
c6931b1f9f
commit
ab3c47c615
1 file changed
+15
-4
@@ -210,6 +210,7 @@ class WebSocketClinet:
|
||||
is_end = False
|
||||
frames = []
|
||||
# status buffer
|
||||
single_chat_finish = False
|
||||
slience_bgn_t = time.time()
|
||||
slience_time = 0
|
||||
print("Start recording...")
|
||||
@@ -242,6 +243,9 @@ class WebSocketClinet:
|
||||
|
||||
# 短时沉默结束单次对话:沉默时间超过一定时间段(0.5s左右),则发送数据
|
||||
if slience_time > recorder.min_act_time:
|
||||
single_chat_finish = True
|
||||
|
||||
if single_chat_finish:
|
||||
is_end = True
|
||||
is_bgn = False
|
||||
|
||||
@@ -261,9 +265,11 @@ class WebSocketClinet:
|
||||
if stream_reset_status:
|
||||
frames.clear()
|
||||
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':
|
||||
recorder.hardware.set_led_off("blue")
|
||||
elif self.speaking_event.is_set():
|
||||
@@ -330,6 +336,8 @@ class WebSocketClinet:
|
||||
|
||||
# 发送数据
|
||||
for queue_data in QueueIterator(self.client_queue):
|
||||
# 发送音频数据
|
||||
if queue_data[0] == 'audio':
|
||||
|
||||
# 当唤醒状态被关闭时,退出循环
|
||||
if not self.wakeup_event.is_set():
|
||||
@@ -340,10 +348,9 @@ class WebSocketClinet:
|
||||
|
||||
# 播放时不得发送数据,默认废消息
|
||||
if self.speaking_event.is_set() and not self.listening_event.is_set():
|
||||
client.close_client()
|
||||
break
|
||||
|
||||
# 发送音频数据
|
||||
if queue_data[0] == 'audio':
|
||||
audio_dict = queue_data[1]
|
||||
|
||||
client.send_per_data(
|
||||
@@ -353,6 +360,10 @@ class WebSocketClinet:
|
||||
is_end=audio_dict['is_end'],
|
||||
encoding='base64',
|
||||
)
|
||||
# is_end后切换播放模式
|
||||
if audio_dict['is_end']:
|
||||
self.listening_event.clear()
|
||||
self.speaking_event.set()
|
||||
|
||||
if not self.wakeup_event.is_set():
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user