This commit is contained in:
2026-04-14 18:23:41 +03:00

View File

@@ -3,7 +3,7 @@ import sys
from .config import GATEWAY_URL, AGENT, AGENTS, log from .config import GATEWAY_URL, AGENT, AGENTS, log
from .audio import record from .audio import record
from .tts import speak, stop_speaking from .tts import speak, stop_speaking, is_speaking
from .llm import ask_agent_stream, is_reset_command, VOICE_SESSION_KEY from .llm import ask_agent_stream, is_reset_command, VOICE_SESSION_KEY
WAKE_THRESHOLD = float(os.getenv("WAKE_THRESHOLD", "0.5")) WAKE_THRESHOLD = float(os.getenv("WAKE_THRESHOLD", "0.5"))
@@ -110,6 +110,12 @@ def run_with_porcupine():
print(f"PREDICTION cosmo: {cosmo_score:.3f}") print(f"PREDICTION cosmo: {cosmo_score:.3f}")
if cosmo_score > WAKE_THRESHOLD: if cosmo_score > WAKE_THRESHOLD:
if is_speaking():
# Barge-in: прерываем TTS
print("✋ Barge-in: прерываю ответ")
stop_speaking()
cosmo_model.reset()
continue
stream.stop_stream() stream.stop_stream()
_conversation_loop("cosmo", "Cosmo") _conversation_loop("cosmo", "Cosmo")
cosmo_model.reset() cosmo_model.reset()