修复无声音导致的 all_audio_received问题
This commit is contained in:
parent
01d55be032
commit
997691cc2b
@ -7,24 +7,26 @@
|
||||
使用增强版语音检测器
|
||||
"""
|
||||
|
||||
import base64
|
||||
import gzip
|
||||
import json
|
||||
import multiprocessing as mp
|
||||
import os
|
||||
import queue
|
||||
import time
|
||||
import threading
|
||||
import time
|
||||
import wave
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
import numpy as np
|
||||
import pyaudio
|
||||
from enum import Enum
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional, List, Dict, Any
|
||||
import json
|
||||
import wave
|
||||
import os
|
||||
import requests
|
||||
|
||||
from enhanced_voice_detector import EnhancedVoiceDetector
|
||||
from process_logger import ProcessLogger
|
||||
|
||||
import requests
|
||||
import base64
|
||||
import gzip
|
||||
|
||||
class RecordingState(Enum):
|
||||
"""录音状态枚举"""
|
||||
@ -1437,7 +1439,7 @@ class OutputProcess:
|
||||
if not self.end_signal_received:
|
||||
return False
|
||||
|
||||
print(f"🔍 增强播放完成检查开始...")
|
||||
# print(f"🔍 增强播放完成检查开始...")
|
||||
|
||||
# 更新状态变量
|
||||
self.pre_buffer_empty = (len(self.preload_buffer) == 0)
|
||||
@ -1450,19 +1452,19 @@ class OutputProcess:
|
||||
current_time = time.time()
|
||||
time_since_last_chunk = current_time - self.last_audio_chunk_time
|
||||
|
||||
print(f"🔍 增强播放完成检查详情:")
|
||||
print(f" - end_signal_received: {self.end_signal_received}")
|
||||
print(f" - llm_generation_complete: {self.llm_generation_complete}")
|
||||
print(f" - tts_generation_complete: {self.tts_generation_complete}")
|
||||
print(f" - all_audio_received: {self.all_audio_received}")
|
||||
print(f" - tts_queue_size: {tts_queue_size}")
|
||||
print(f" - tts_buffer_size: {len(self.tts_buffer)}")
|
||||
print(f" - playback_buffer: {len(self.playback_buffer)}")
|
||||
print(f" - preload_buffer: {len(self.preload_buffer)}")
|
||||
print(f" - currently_playing: {self.currently_playing}")
|
||||
print(f" - is_playing: {self.is_playing}")
|
||||
print(f" - last_audio_chunk_time: {self.last_audio_chunk_time}")
|
||||
print(f" - time_since_last_chunk: {time_since_last_chunk:.3f}秒")
|
||||
# print(f"🔍 增强播放完成检查详情:")
|
||||
# print(f" - end_signal_received: {self.end_signal_received}")
|
||||
# print(f" - llm_generation_complete: {self.llm_generation_complete}")
|
||||
# print(f" - tts_generation_complete: {self.tts_generation_complete}")
|
||||
# print(f" - all_audio_received: {self.all_audio_received}")
|
||||
# print(f" - tts_queue_size: {tts_queue_size}")
|
||||
# print(f" - tts_buffer_size: {len(self.tts_buffer)}")
|
||||
# print(f" - playback_buffer: {len(self.playback_buffer)}")
|
||||
# print(f" - preload_buffer: {len(self.preload_buffer)}")
|
||||
# print(f" - currently_playing: {self.currently_playing}")
|
||||
# print(f" - is_playing: {self.is_playing}")
|
||||
# print(f" - last_audio_chunk_time: {self.last_audio_chunk_time}")
|
||||
# print(f" - time_since_last_chunk: {time_since_last_chunk:.3f}秒")
|
||||
|
||||
|
||||
# 检查TTS是否正在生成 - 移除自动修正逻辑
|
||||
@ -1470,10 +1472,10 @@ class OutputProcess:
|
||||
|
||||
# TTS正在生成的条件:队列中有任务 或 还有待处理的缓冲区内容 或 TTS生成未完成
|
||||
tts_is_generating = (tts_queue_size > 0 or len(self.tts_buffer) > 0 or not self.tts_generation_complete)
|
||||
print(f" - tts_is_generating: {tts_is_generating}")
|
||||
print(f" - pre_buffer_empty: {self.pre_buffer_empty}")
|
||||
print(f" - playback_buffer_empty: {self.playback_buffer_empty}")
|
||||
print(f" - no_active_playback: {self.no_active_playback}")
|
||||
# print(f" - tts_is_generating: {tts_is_generating}")
|
||||
# print(f" - pre_buffer_empty: {self.pre_buffer_empty}")
|
||||
# print(f" - playback_buffer_empty: {self.playback_buffer_empty}")
|
||||
# print(f" - no_active_playback: {self.no_active_playback}")
|
||||
|
||||
# 特殊处理1:如果没有任何音频数据,暂时不设置all_audio_received,等待TTS生成
|
||||
# 注意:这里不自动设置all_audio_received,因为可能TTS还在生成中
|
||||
@ -1481,15 +1483,15 @@ class OutputProcess:
|
||||
|
||||
# 特殊处理2:如果all_audio_received为False但其他条件都满足,强制设置为True
|
||||
# 移除自动修正all_audio_received的逻辑,等待真正的音频数据
|
||||
print(f"🔍 播放状态检查(移除自动修正机制):")
|
||||
print(f" - llm_generation_complete: {self.llm_generation_complete}")
|
||||
print(f" - tts_generation_complete: {self.tts_generation_complete}")
|
||||
print(f" - all_audio_received: {self.all_audio_received}")
|
||||
print(f" - pre_buffer_empty: {self.pre_buffer_empty}")
|
||||
print(f" - playback_buffer_empty: {self.playback_buffer_empty}")
|
||||
print(f" - no_active_playback: {self.no_active_playback}")
|
||||
print(f" - tts_queue_size == 0: {tts_queue_size == 0}")
|
||||
print(f" - not tts_is_generating: {not tts_is_generating}")
|
||||
# print(f"🔍 播放状态检查(移除自动修正机制):")
|
||||
# print(f" - llm_generation_complete: {self.llm_generation_complete}")
|
||||
# print(f" - tts_generation_complete: {self.tts_generation_complete}")
|
||||
# print(f" - all_audio_received: {self.all_audio_received}")
|
||||
# print(f" - pre_buffer_empty: {self.pre_buffer_empty}")
|
||||
# print(f" - playback_buffer_empty: {self.playback_buffer_empty}")
|
||||
# print(f" - no_active_playback: {self.no_active_playback}")
|
||||
# print(f" - tts_queue_size == 0: {tts_queue_size == 0}")
|
||||
# print(f" - not tts_is_generating: {not tts_is_generating}")
|
||||
|
||||
# 检查是否所有条件都满足 - 使用更新的状态变量,添加TTS生成状态检查
|
||||
all_conditions_met = (
|
||||
@ -1503,17 +1505,17 @@ class OutputProcess:
|
||||
not tts_is_generating # 新增:确保TTS不在生成中
|
||||
)
|
||||
|
||||
print(f"🔍 最终条件检查结果:")
|
||||
print(f" - all_conditions_met: {all_conditions_met}")
|
||||
print(f" - 各个条件详情:")
|
||||
print(f" * llm_generation_complete: {self.llm_generation_complete}")
|
||||
print(f" * tts_generation_complete: {self.tts_generation_complete}")
|
||||
print(f" * all_audio_received: {self.all_audio_received}")
|
||||
print(f" * pre_buffer_empty: {self.pre_buffer_empty}")
|
||||
print(f" * playback_buffer_empty: {self.playback_buffer_empty}")
|
||||
print(f" * no_active_playback: {self.no_active_playback}")
|
||||
print(f" * tts_queue_size == 0: {tts_queue_size == 0}")
|
||||
print(f" * not tts_is_generating: {not tts_is_generating}")
|
||||
# print(f"🔍 最终条件检查结果:")
|
||||
# print(f" - all_conditions_met: {all_conditions_met}")
|
||||
# print(f" - 各个条件详情:")
|
||||
# print(f" * llm_generation_complete: {self.llm_generation_complete}")
|
||||
# print(f" * tts_generation_complete: {self.tts_generation_complete}")
|
||||
# print(f" * all_audio_received: {self.all_audio_received}")
|
||||
# print(f" * pre_buffer_empty: {self.pre_buffer_empty}")
|
||||
# print(f" * playback_buffer_empty: {self.playback_buffer_empty}")
|
||||
# print(f" * no_active_playback: {self.no_active_playback}")
|
||||
# print(f" * tts_queue_size == 0: {tts_queue_size == 0}")
|
||||
# print(f" * not tts_is_generating: {not tts_is_generating}")
|
||||
|
||||
if all_conditions_met:
|
||||
print(f"✅ 所有播放完成条件已满足,进行时间检查...")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user