import asyncio import logging from backend.ws.agent_ws import ws_manager async def emit_wake_word(agent="JARVIS", confidence=0.99): await ws_manager.broadcast({ "event": "voice:wake_word", "payload": {"agent": agent, "confidence": confidence} }) async def emit_transcript(text, is_final=True): await ws_manager.broadcast({ "event": "voice:transcript", "payload": {"text": text, "is_final": is_final} }) async def emit_speaking_start(agent="JARVIS"): await ws_manager.broadcast({ "event": "voice:speaking_start", "payload": {"agent": agent} }) async def emit_speaking_end(agent="JARVIS"): await ws_manager.broadcast({ "event": "voice:speaking_end", "payload": {"agent": agent} }) async def start_wake_word_loop(): try: pass # In a real setup, instantiate Model here await asyncio.sleep(5) except asyncio.CancelledError: logging.info("Wake Word Loop cancelled, shutting down cleanly.") return except Exception as e: logging.error(f"openWakeWord initialization failed: {e}") # Could publish to global state for /health check while True: try: await asyncio.sleep(3600) except asyncio.CancelledError: logging.info("Wake Word Loop cancelled, shutting down cleanly.") break