feat: barge-in support — stop TTS when wake word detected during playback
This commit is contained in:
@@ -3,7 +3,7 @@ import sys
|
|||||||
|
|
||||||
from .config import GATEWAY_URL, AGENT, log
|
from .config import GATEWAY_URL, AGENT, 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
|
from .llm import ask_agent_stream, is_reset_command
|
||||||
|
|
||||||
WAKE_THRESHOLD = float(os.getenv("WAKE_THRESHOLD", "0.5"))
|
WAKE_THRESHOLD = float(os.getenv("WAKE_THRESHOLD", "0.5"))
|
||||||
@@ -89,6 +89,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()
|
||||||
|
|||||||
Reference in New Issue
Block a user