Enhances test_streaming_tts.py to support optional Opus encoding for
streaming TTS audio from ElevenLabs to ESP32.
Features:
- Add --opus flag to enable Opus compression
- Accept ESP32 IP as command-line argument
- Buffer PCM chunks into 20ms frames (640 bytes) for Opus encoding
- Send with length-prefixed framing (compatible with ESP32 decoder)
- Display compression statistics when using Opus
Usage:
python test_streaming_tts.py [ESP32_IP] [--opus]
Results with Opus:
- Compression ratio: ~14.5x (248KB PCM → 17KB Opus)
- Bandwidth: 256 kbps → ~17 kbps (93% reduction)
- Maintains streaming latency (~2s to first chunk)
- High quality voice for human listening
Tested successfully with ElevenLabs API streaming to ESP32-S3.
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)