feat(notifier): push state events to Smart Home Tablet overlay
Adds a thin HTTP bridge so the tablet at https://tablet.digital-home.site shows a Siri-style overlay reflecting the current assistant state (wake / command / response / idle / error). Non-fatal: if the tablet is offline or TABLET_URL/VOICE_API_KEY are unset, events are silently skipped and the assistant keeps working. - satellite/notifier.py — POST /api/voice/event with bearer token, reused requests.Session for keep-alive, 1.5s timeout - satellite/modes.py — emits wake on activation, command after STT, response after LLM, idle on timeout - satellite/llm.py — emits error on gateway connection/timeout/HTTP - .env.example documents TABLET_URL and VOICE_API_KEY Tablet side (separate repo smart-home-tablet, commit 51c3d60) exposes POST /api/voice/event + GET /api/voice/stream (SSE) and renders a full-screen overlay in components/VoiceOverlay.tsx. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ from .config import GATEWAY_URL, AGENTS, FOLLOWUP_TIMEOUT, MAX_DURATION, log
|
||||
from .audio import record
|
||||
from .tts import speak, stop_speaking
|
||||
from .llm import ask_agent_stream, is_reset_command, VOICE_SESSION_KEY
|
||||
from . import notifier
|
||||
|
||||
WAKE_THRESHOLD = float(os.getenv("WAKE_THRESHOLD", "0.5"))
|
||||
|
||||
@@ -47,15 +48,18 @@ def _conversation_loop(agent_id: str, agent_name: str = "Cosmo"):
|
||||
text = record(initial_silence_timeout=timeout)
|
||||
if not text:
|
||||
print("😴 Тишина, жду активации...\n")
|
||||
notifier.idle()
|
||||
return
|
||||
|
||||
print(f"📝 Ты → {agent_name}: {text}")
|
||||
notifier.command(text, agent_id)
|
||||
|
||||
if _handle_reset(text, agent_id):
|
||||
continue
|
||||
|
||||
response = ask_agent_stream(text, agent_id=agent_id)
|
||||
print(f"🤖 {agent_name}: {response}\n")
|
||||
notifier.response(response, agent_id)
|
||||
|
||||
|
||||
def run_with_enter():
|
||||
@@ -67,6 +71,7 @@ def run_with_enter():
|
||||
try:
|
||||
input("⏎ Нажми Enter и говори...")
|
||||
stop_speaking() # barge-in
|
||||
notifier.wake("cosmo")
|
||||
_conversation_loop("cosmo", "Cosmo")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
@@ -110,7 +115,9 @@ def run_with_porcupine():
|
||||
print(f"PREDICTION cosmo: {cosmo_score:.3f}")
|
||||
|
||||
if cosmo_score > WAKE_THRESHOLD:
|
||||
print("✅ Услышал 'Космо'!")
|
||||
stop_speaking() # на случай если TTS ещё играет
|
||||
notifier.wake("cosmo")
|
||||
stream.stop_stream()
|
||||
_conversation_loop("cosmo", "Cosmo")
|
||||
cosmo_model.reset()
|
||||
|
||||
Reference in New Issue
Block a user