10 sec timer removed

This commit is contained in:
rahulpscraftech360 2025-08-30 13:54:46 +05:30
parent 00d91a1a7e
commit 1bbc044488
5 changed files with 10 additions and 62 deletions

2
.gitignore vendored
View file

@ -181,5 +181,5 @@ main/manager-api/.vscode
main/manager-web/.webpack_cache/
main/xiaozhi-server/mysql
uploadfile
# *.json
*.json
.vscode

View file

@ -1,12 +1,12 @@
{
"production": {
"chat_servers": [
"ws://192.168.1.179:8000/toy/v1/"
"ws://192.168.1.111:8000/toy/v1/"
]
},
"development": {
"chat_servers": [
"ws://192.168.1.179:8000/toy/v1/"
"ws://192.168.1.111:8000/toy/v1/"
],
"mac_addresss": [
]

View file

@ -19,9 +19,9 @@ import opuslib
# --- Configuration ---
SERVER_IP = "192.168.1.179" # !!! UPDATE with your server's local IP address !!!
SERVER_IP = "192.168.1.111" # !!! UPDATE with your server's local IP address !!!
OTA_PORT = 8003
MQTT_BROKER_HOST = "192.168.1.179" # MQTT gateway IP
MQTT_BROKER_HOST = "192.168.1.111" # MQTT gateway IP
MQTT_BROKER_PORT = 1883

View file

@ -2361,13 +2361,10 @@ class ConnectionHandler:
# Clear ASR audio buffer to prevent processing leftover audio
if hasattr(self, 'asr_audio'):
self.asr_audio.clear()
# Reset VAD recording start time for timeout
# Reset VAD recording start time (no timeout logic needed)
if hasattr(self, 'vad_recording_start_time'):
self.vad_recording_start_time = None
# Reset timeout flag
if hasattr(self, '_timeout_triggered'):
self._timeout_triggered = False
# Also reset listen start time to prevent conflicts
# Also reset listen start time
if hasattr(self, 'listen_start_time'):
self.listen_start_time = None
# Clear ASR audio queue for this specific connection only

View file

@ -62,51 +62,7 @@ class ASRProviderBase(ABC):
else:
have_voice = conn.client_have_voice
# Check for maximum recording timeout (hardcoded 10 seconds)
# This applies when we're actively recording
recording_start_time = None
if hasattr(conn, 'vad_recording_start_time'):
recording_start_time = conn.vad_recording_start_time # Auto VAD mode
elif hasattr(conn, 'listen_start_time'):
recording_start_time = conn.listen_start_time # Manual listen mode
if recording_start_time and not conn.client_voice_stop:
current_time = time.time()
recording_duration = current_time - recording_start_time
max_recording_time = 10.0 # Hardcoded 10 second maximum
# Log every 50 chunks or when approaching timeout
if len(conn.asr_audio) % 50 == 0 or recording_duration >= (max_recording_time - 1):
logger.bind(tag=TAG).debug(f"Recording duration: {recording_duration:.2f}s, max: {max_recording_time}s, audio chunks: {len(conn.asr_audio)}")
if recording_duration >= max_recording_time:
# Use a timeout flag to prevent multiple timeout messages
if not hasattr(conn, '_timeout_triggered') or not conn._timeout_triggered:
logger.bind(tag=TAG).info(f"Maximum recording time reached ({recording_duration:.2f}s) - forcing voice stop")
conn._timeout_triggered = True
# Force voice stop using the same logic as VAD silence detection
conn.client_voice_stop = True
have_voice = False
# Process any accumulated audio before resetting (same as normal VAD flow)
if len(conn.asr_audio) > 20:
logger.bind(tag=TAG).info(f"Processing {len(conn.asr_audio)} audio chunks after timeout")
asr_audio_task = conn.asr_audio.copy()
conn.asr_audio.clear()
# Reset states and clear timeout flag
conn.reset_vad_states()
# Process the accumulated audio asynchronously
asyncio.create_task(self.handle_voice_stop(conn, asr_audio_task))
else:
logger.bind(tag=TAG).debug(f"Timeout reached but insufficient audio ({len(conn.asr_audio)} chunks) - resetting without processing")
# No significant audio to process, just reset everything
conn.reset_vad_states()
return # Exit early like VAD does
# If timeout already triggered, just skip this audio and return
return
# 10 second timeout removed - VAD will handle voice detection naturally
# Debug logging
if not hasattr(conn, '_asr_log_counter'):
@ -134,13 +90,8 @@ class ASRProviderBase(ABC):
# Clear the just_started_listening flag when actual voice is detected
if hasattr(conn, 'just_started_listening'):
conn.just_started_listening = False
# Start recording timer for VAD-based sessions (only if not already set)
if not hasattr(conn, 'vad_recording_start_time') or conn.vad_recording_start_time is None:
conn.vad_recording_start_time = time.time()
# Reset timeout flag when starting new recording session
if hasattr(conn, '_timeout_triggered'):
conn._timeout_triggered = False
logger.bind(tag=TAG).debug("VAD recording session started")
# VAD recording session started (no timeout needed)
logger.bind(tag=TAG).debug("VAD recording session started")
# Add pre-buffered audio to the beginning of ASR audio
conn.asr_audio = list(conn.audio_pre_buffer) + conn.asr_audio
conn.audio_pre_buffer.clear()