Currently path C-light: duck speaks raw int16 PCM (32 KB/sec) over WS to the relay; relay JSON+base64 wraps it for ElevenAgents.
Path C-full: encode Opus on the chip (~3 KB/sec @ 24 kbps voip), relay decodes Opus → PCM → ElevenAgents and the reverse for incoming agent audio.
Why bother:
- Eliminates "spk stream full / mic stream full" warnings during long agent answers
- ~10× bandwidth reduction makes cellular hotspot / weak WiFi viable
- Matches ElatoAI's architecture (the only battle-tested ESP32-S3 → ElevenLabs project at scale uses Opus precisely because raw PCM is on the edge of S3's TLS throughput)
- Multiple ducks on one network won't congest
Plan:
- Firmware: pull in
esphome__micro-opus (URAM already uses it for playback) and wire encode + decode. Roughly 200 lines: init encoder/decoder, replace mic_task → ws_send_task PCM path with Opus encode, replace on_binary PCM-to-spk_stream with Opus decode.
- Relay:
pip install opuslib. In _duck_to_eleven decode Opus → PCM → base64+JSON. In _eleven_to_duck PCM → encode Opus → binary frame to duck. ~30 lines.
Costs:
- Lossy (Opus voip 24 kbps is very good but not bit-perfect)
- ~5–10% extra CPU on S3 for encode at 240 MHz
- ~80 KB additional flash for the codec
Defer until: the Bambu printer-state plumbing is end-to-end working through path C-light. We've already validated the architecture without compression; Opus is a refinement, not a blocker.
References:
Currently path C-light: duck speaks raw int16 PCM (32 KB/sec) over WS to the relay; relay JSON+base64 wraps it for ElevenAgents.
Path C-full: encode Opus on the chip (~3 KB/sec @ 24 kbps voip), relay decodes Opus → PCM → ElevenAgents and the reverse for incoming agent audio.
Why bother:
Plan:
esphome__micro-opus(URAM already uses it for playback) and wire encode + decode. Roughly 200 lines: init encoder/decoder, replacemic_task → ws_send_taskPCM path with Opus encode, replaceon_binaryPCM-to-spk_stream with Opus decode.pip install opuslib. In_duck_to_elevendecode Opus → PCM → base64+JSON. In_eleven_to_duckPCM → encode Opus → binary frame to duck. ~30 lines.Costs:
Defer until: the Bambu printer-state plumbing is end-to-end working through path C-light. We've already validated the architecture without compression; Opus is a refinement, not a blocker.
References: