修复无声音导致的 all_audio_received问题
This commit is contained in:
parent
26a42452c8
commit
01d55be032
@ -1114,12 +1114,17 @@ class OutputProcess:
|
|||||||
self.end_signal_received = True
|
self.end_signal_received = True
|
||||||
self.end_signal_time = time.time() # 记录收到结束信号的时间
|
self.end_signal_time = time.time() # 记录收到结束信号的时间
|
||||||
|
|
||||||
# 延迟设置all_audio_received,确保音频真正开始播放后再设置
|
# 关键修复:如果已经通过ALL_AUDIO_RECEIVED信号设置了True,则不要重置为False
|
||||||
# 暂时设置为False,让播放启动逻辑处理
|
# 这解决了语音识别失败时all_audio_received被重置的问题
|
||||||
|
if not self.all_audio_received:
|
||||||
|
# 只有在all_audio_received为False时才设置为False
|
||||||
|
# 如果已经是True(如语音识别失败处理),保持True
|
||||||
self.all_audio_received = False
|
self.all_audio_received = False
|
||||||
|
else:
|
||||||
|
print(f"🔧 保持all_audio_received=True(已通过语音识别失败处理设置)")
|
||||||
print(f"📥 收到结束信号,状态变化:")
|
print(f"📥 收到结束信号,状态变化:")
|
||||||
print(f" - end_signal_received: True")
|
print(f" - end_signal_received: True")
|
||||||
print(f" - all_audio_received: False (延迟设置)")
|
print(f" - all_audio_received: {self.all_audio_received} ({'保持True' if self.all_audio_received else '延迟设置'})")
|
||||||
print(f" - completion_sent: False")
|
print(f" - completion_sent: False")
|
||||||
print(f" - playback_completed: False")
|
print(f" - playback_completed: False")
|
||||||
|
|
||||||
@ -1209,6 +1214,13 @@ class OutputProcess:
|
|||||||
self.tts_generation_complete = True
|
self.tts_generation_complete = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if isinstance(audio_data, str) and audio_data.startswith("ALL_AUDIO_RECEIVED:"):
|
||||||
|
# 语音识别失败时设置的all_audio_received信号
|
||||||
|
print(f"📥 输出进程收到ALL_AUDIO_RECEIVED信号")
|
||||||
|
self.all_audio_received = True
|
||||||
|
print(f"🔧 设置all_audio_received=True(语音识别失败处理)")
|
||||||
|
continue
|
||||||
|
|
||||||
# 音频数据处理
|
# 音频数据处理
|
||||||
if isinstance(audio_data, bytes):
|
if isinstance(audio_data, bytes):
|
||||||
# 更新最后收到音频数据的时间
|
# 更新最后收到音频数据的时间
|
||||||
|
|||||||
@ -643,6 +643,11 @@ class ControlSystem:
|
|||||||
# 发送TTS完成信号
|
# 发送TTS完成信号
|
||||||
tts_complete_command = "TTS_COMPLETE:"
|
tts_complete_command = "TTS_COMPLETE:"
|
||||||
self.output_audio_queue.put(tts_complete_command)
|
self.output_audio_queue.put(tts_complete_command)
|
||||||
|
# 关键修复:处理失败时也要发送all_audio_received=True信号
|
||||||
|
# 这解决了语音识别失败但TTS完成信号已发送的死锁问题
|
||||||
|
all_audio_received_command = "ALL_AUDIO_RECEIVED:"
|
||||||
|
self.output_audio_queue.put(all_audio_received_command)
|
||||||
|
print(f"🔧 处理失败,发送all_audio_received=True信号以避免死锁")
|
||||||
# 发送结束信号
|
# 发送结束信号
|
||||||
self.output_audio_queue.put(None)
|
self.output_audio_queue.put(None)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user