Implements Opus decoding on ESP32 for TTS playback, achieving 14-16x
compression over raw PCM. This improves WiFi throughput margin from 2.2x
to 30x+, enabling reliable operation throughout the home even with poor
WiFi conditions.
Key changes:
- Add Opus decoder to ESP32 firmware with dedicated 32KB FreeRTOS task
- Implement length-prefixed TCP framing for variable-bitrate Opus frames
- Update header protocol: header[5] = compression type (0=PCM, 1=μ-law, 2=Opus)
- Auto-detect USB port in flash and serial monitor scripts
- Add test script with opuslib encoder supporting WAV/M4A/MP3 input
- Document architecture and design rationale for μ-law/UDP (mic) vs Opus/TCP (speaker)
Performance:
- Compression: 640 bytes PCM → 35-50 bytes Opus per 20ms frame (14-16x)
- Bandwidth: 256 kbps → 16 kbps (94% reduction)
- WiFi margin: 2.2x → 30x+ throughput safety margin
- CPU usage: ~10-20% during playback on ESP32-S3
- Quality: High-fidelity voice suitable for human listening
🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit adds audio compression and fixes critical I2S configuration
issues that prevented audio playback on ESP32-S3 V3 boards.
Key Changes:
- Fix I2S channel from RIGHT to LEFT (V3 board requirement)
- Fix deprecated I2S_COMM_FORMAT_I2S to I2S_COMM_FORMAT_STAND_I2S
- Add μ-law compression for 2x bandwidth reduction (960→480 bytes/packet)
- Add DC offset removal for microphone to fix compression artifacts
- Add DISABLE_HARDWARE_MUTE option for boards without mute switch
- Improve mute button behavior to control mic_timeout
New Files:
- onjuino/audio_compression.h: μ-law encoding/decoding implementation
- flash_firmware.sh: Automated compilation and flashing script
- serial_monitor.py: Interactive serial monitor with auto-reconnect
- test_mic_receiver.py: UDP audio recording and compression testing
- test_speaker.py: Speaker testing with local WAV file
- test_streaming_tts.py: ElevenLabs streaming TTS performance testing
- record_from_esp32.py: Simple recording script for testing
- TESTING.md: Testing documentation
Fixes:
- I2S audio output now works on V3 boards (issue #57, #75)
- Microphone compression produces valid audio data
- Serial reset command now works properly (ESP.restart vs esp_restart)
🤖 Generated with [Claude Code](https://claude.com/claude-code)