update: TTS复用链接,VAD双阈值判断

This commit is contained in:
Sakura-RanChen
2025-07-03 09:16:06 +08:00
parent 20adbadc02
commit 69cac9d40a
4 changed files with 52 additions and 19 deletions
+6
View File
@@ -17,6 +17,7 @@ from core.utils.util import (
filter_sensitive_info,
)
from typing import Dict, Any
from collections import deque
from core.utils.modules_initialize import (
initialize_modules,
initialize_tts,
@@ -112,6 +113,8 @@ class ConnectionHandler:
self.client_have_voice = False
self.last_activity_time = 0.0 # 统一的活动时间戳(毫秒)
self.client_voice_stop = False
self.client_voice_window = deque(maxlen=5)
self.last_is_voice = False
# asr相关变量
# 因为实际部署时可能会用到公共的本地ASR,不能把变量暴露给公共ASR
@@ -858,6 +861,9 @@ class ConnectionHandler:
elif self.websocket:
await self.websocket.close()
if self.tts:
await self.tts.close()
# 最后关闭线程池(避免阻塞)
if self.executor:
self.executor.shutdown(wait=False)