Repository navigation
fix: migrate StackChan voice assistant to esphome-audio-stack - #120
Conversation
|
Thanks for the PR, I have a AW88298 PR on the way. Maybe we can wait until the PR gets reviewed (merged), then switch to hardware AEC on TDM. That should give us better audio results while reducing CPU usage. |
|
n-IA-hane/esphome-audio-stack#16 is merged into dev. And I have added some additional TDM configurations (still testing on cores3 for better performance). |
There was a problem hiding this comment.
🟡 Changes recommended
The obsolete standalone amplifier driver fails by probing the device while it is held in reset, and unresolved dependency-pinning and custom-image regressions remain.
3 open issues
What changed in this PR
Migrates the shared StackChan voice-assistant package from esphome-intercom to esphome-audio-stack, following the compatibility repair in #93.
Changes:
- Replaces duplex audio components with Audio Stack and configures codec management and hardware echo-reference routing.
- Raises the minimum ESPHome version, adjusts ESP-IDF settings, and updates the playback script for const audio files.
- Updates external component sources and migrates image entries to
platform: filewith explicit URLs.
| File | Description |
|---|---|
common/stackchan-voice-assistant-base.yaml |
Updates StackChan audio integration, runtime settings, playback types, and image configuration. |
Review effort: Balanced
|
I had some more adjustments and modifications, they aren't just about the esphome-audio-stack; they also cover other aspects. I'm very sorry I didn't keep each PR focused on its own content (there were quite a few local modifications). Mainly migrate to the esp_afe instead of esp_aec for better AEC result, however only one mic was used for AEC, since dual mic configuration lags on my side and constantly trigger WDT. I have tested on at my end and I can wake the device while streaming the music. |
|
Whatever helps improving it 😊 |
pboushy
left a comment
There was a problem hiding this comment.
A few feedback items from me.
In addition, the last commit is a ton of changes in one commit and will make troubleshooting and reverting if needed a mess. Can you split it up?
I would propose breaking it up into the below (not in order, numbering is for reference):
- feat: Migrate esp_aec to esp_afe
- feat: Migrate media player to sendspin
- feat: Add new IR proxy
- feat: Add light effect to voice assistant trigger
- feat: Adjust
hi_stackchanwakeword sensitivity Remove Wake Word engine location
Please include the reason for 1, 2, and 6 in the commit messages.
|
Too many changes combined with vague commit messages make a PR hard to review and move forward. I'll continue addressing the review feedback. |
- Move the custom components from this repo to m5stack/esphome@m5-dev so they can be prepared for upstream ESPHome PRs. - Move esphome-audio-stack from v2026.11.0 to dev: the AW88298 codec and the TDM reference options are not in the release yet. The audio stack now owns the ES7210 input, the AW88298 output and the AW_RST pin, so drop the standalone reset switch. - Configure the four TDM slots: MIC1 on slot 0, the hardware AEC reference on slot 1, playback on slot 0, and keep the buffers and the audio task stack in PSRAM. - Use platform: file for the images to fix the ESPHome 2026.10 deprecation warning. - Document the sdkconfig tuning: the cache and PSRAM options reduce PSRAM latency and move code, read-only data, Bluetooth and mbedTLS buffers to PSRAM, which speeds up micro wake word.
Replace the single-mic esp_aec processor with the full ESP-SR front end. The AFE uses the tuned sr/low_cost profile with AEC on; NS and AGC stay off because the codec gain staging handles the level. Use a single microphone: Espressif's ESP32-S3 benchmark puts the dual-mic MMR/BSS profile at 23.7% feed + 22.9% fetch of one core versus 8.8% + 9.8% for the single-mic profile, and the dual-mic feed path dropped 14.6% of its frames while music was playing. Single-mic AEC measured 0% dropped frames with 28 dB of echo return loss. The codec now owns the ES7210 input and the AW88298 output, so remove the standalone audio_adc/esp_aec components and the unused m5ioe1 test output. Lower the analog mic gain to 18 dB for headroom and compensate with the new post-AFE Mic Gain number; raise the reference gain to 24 dB and use the 5 V PA voltage expected by the CoreS3 BSP. Rename the microphone entity to voice_mic because the voice assistant and micro wake word consume the same AFE-processed stream, and add start_wake_word so the engine is restarted consistently after voice assistant sessions and unmute. Raise the BSP I2C bus to 100 kHz for the codec/PMU traffic. The loopTask priority change is a workaround for the AFE feed deadline; keep it isolated here so it can be revisited separately.
Replace the legacy speaker media player with speaker_source and the sendspin media player. The new pipelines separate music (two channels, HTTP and sendspin sources) from announcements (audio_file and HTTP sources), which lets the stack duck music while TTS or the wake sound plays instead of stopping playback. Add the sendspin hub/source and the audio_file media source, restore ducking when an announcement ends and when the voice assistant finishes, and let the player restart micro wake word when user playback ends. play_sound now takes a media URL string because the speaker_source API plays audio through the media source pipeline.
Expose the existing IR TX/RX pins as ir_rf_proxy entities so the device can learn and replay arbitrary IR codes from Home Assistant. This is an experimental convenience on top of the Coolix climate support; the receiver no longer dumps every protocol to the log.
Add a partition light over the 12-LED bar and drive it from the voice assistant phase: initializing, listening, thinking, replying, error, muted and not-ready patterns. The pattern follows the user's chosen bar colour when the bar is on and falls back to assistant cyan. The effect is selected from draw_display so it stays in sync with the display and with connection changes.
Add cutoffs for the hi_stackchan model, measured on LibriSpeech dev-clean because it has no DipCo figures. The model is more trigger happy than the others, so use smaller steps and keep the manifest default at the middle tier.
Always run micro wake word on the ESP32-S3. Streaming all microphone audio to Home Assistant just for wake word detection adds latency and network overhead, and the on-device model is fast enough. This also drops the start_continuous path and the on_end workaround that existed only for the "In Home Assistant" mode. The same cleanup will be rolled out to the other ESP32-S3 voice assistant devices.
The dev branch moved to ESPHome 2026.12.0, so the current config no longer validates with the declared minimum 2026.10.0. v2026.12.0-dev is the tested snapshot with AW88298, esp_afe and the TDM reference support, and it validates with ESPHome 2026.10.2. Pin it so builds do not change between reviews; move to a stable tag once one contains these features.
b5bbba4 to
bcf3c95
Compare
|
History rewritten in $ esphome config common/stackchan-voice-assistant-base.yaml
INFO ESPHome 2026.10.0
INFO Reading configuration common/stackchan-voice-assistant-base.yaml...
...
INFO Configuration is valid!
$ esphome compile common/stackchan-voice-assistant-base.yaml
INFO ESPHome 2026.10.0
INFO Reading configuration common/stackchan-voice-assistant-base.yaml...
stackchan-voice.bin binary size 0x52a410 bytes. Smallest app partition is 0x7c0000 bytes. 0x295bf0 bytes (33%) free.
RAM: [===== ] 48.3% (used 165212 bytes from 341760 bytes)
Flash: [======= ] 66.6% (used 5415828 bytes from 8126464 bytes)
INFO Creating factory.bin...
...
INFO Successfully compiled program.Config and compile/test looks good to me.
|


Follow-up to #93 and the migration discussion in #92.
This moves the StackChan voice assistant from
esphome-intercom/i2s_audio_duplexto esphome-audio-stack and reworks the audio pipeline around it.Review updates
dev.Audio pipeline
esphome-intercom@v2026.5.0→esphome-audio-stack@v2026.12.0-dev(pinned; thedevbranch now requires ESPHome 2026.12.0, which is not released yet)esp_aec→esp_afewith the tunedsr/low_costprofile, single-mic AEC and the hardware reference on TDM slot 1. Dual-mic MMR/BSS was too expensive and dropped frames; single-mic AEC measured 0% dropped frames with 28 dB ERLE.audio_adc/audio_dacand theaw_rstswitch are gone.voice_assistantno longer applies extra NS/AGC/volume;voice_micis shared by the voice assistant and micro wake word.Media player
speakermedia player →speaker_source+sendspinmedia player.play_soundnow takes a media URL string.Other changes
ir_rf_proxy) for raw IR TX/RX from Home Assistant (experimental).hi_stackchanwake word sensitivity cutoffs measured on LibriSpeech dev-clean.Validation
esphome configpasses with ESPHome 2026.10.2 against the pinned audio stack./cc @n-IA-hane