* Improve HeyGen LiveAvatar plugin reliability and performance - Add WebSocket ready gate: wait for session.state_updated connected event before sending commands (prevents silently dropped messages) - Add keep-alive mechanism: send session.keep_alive every 2.5 min to prevent 5-minute inactivity timeout - Optimize audio chunking: 600ms first chunk for faster initial response, 1s subsequent chunks for efficient streaming - Fix audio buffer flush: send remaining buffered audio on utterance end instead of discarding it - Fix WS state cleanup: properly reset connected/ready state when WebSocket drops unexpectedly - Add livekit_config passthrough in LiveAvatar session token creation - Replace stray print() with logger.debug() * Fix HeyGenOutputTransport.start() signature and use 400ms first chunk - Update transport.py to match new client.start() signature (no audio_chunk_size param) - Change first chunk size from 600ms to 400ms per feedback * Fix transport audio resampling and client.start() error propagation - Add audio resampling in HeyGenOutputTransport.write_audio_frame() to ensure audio is always 24kHz before sending to HeyGen (was sending at pipeline sample rate, causing garbled audio) - Raise exception on WS ready timeout instead of silently returning, preventing transport from appearing ready when WS connection failed * Fix session readiness gate to work with LITE mode LITE mode does not send session.state_updated WS events. Instead, use a dual-signal _session_ready event that fires on either: - WS session.state_updated connected (FULL mode) - LiveKit participant connected (LITE mode) Also reorder start() to connect both WS and LiveKit before waiting, since the WS events may depend on LiveKit being connected. Verified with live sandbox session - all tests pass. * Simplify session readiness to use only WS ready gate Remove _session_ready dual-signal and use only _ws_ready, which fires on the session.state_updated connected WS event. Increase timeout to 30s. LiveKit is connected before waiting so the WS event can arrive. * Reduce WS ready gate timeout back to 10s * Remove WS ready gate (session.state_updated not reliably received) The session.state_updated connected event is not reliably received via the websockets library. Remove the gate for now and assume the session is ready after WS + LiveKit connect. Keep-alive, chunking, buffer flush, state cleanup, and other improvements remain.
1.2 MiB
1.2 MiB