Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,19 @@ LVA_PULSE_COOKIE="/run/user/${LVA_USER_ID}/pulse/cookie"
### Audio output device (optional):
# AUDIO_OUTPUT_DEVICE="default"

<<<<<<< feat/docker-aec-env-var
### Acoustic Echo Cancellation (optional):
# Automatically loads the PulseAudio AEC module and sets AUDIO_INPUT_DEVICE
# to the echo-cancelled source. See docs/enabling_aec.md for details and
# for PipeWire / manual setup instructions.
# ENABLE_ECHO_CANCEL="1"
=======
### Mic Gain (optional) passed as an argument to LVA will overide the value in thepreferences file on boot but can be changed at runtime in Home Assistant:
# MIC_AUTO_GAIN="0"

### Mic Noise Suppression (optional) passed as an argument to LVA will overide the value in thepreferences file on boot but can be changed at runtime in Home Assistant:
# MIC_NOISE_SUPPRESSION="0"
>>>>>>> main

### Enable thinking sound (optional):
# ENABLE_THINKING_SOUND="1"
Expand Down
18 changes: 18 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ for i in $(seq 1 $CP_MAX_RETRIES); do
done


### Acoustic Echo Cancellation
# Convenience wrapper for the setup described in docs/enabling_aec.md.
# Loads the PulseAudio AEC module and sets AUDIO_INPUT_DEVICE automatically.
# See docs/enabling_aec.md for manual setup and PipeWire instructions.
if [ "${ENABLE_ECHO_CANCEL}" = "1" ]; then
if pactl list modules short 2>/dev/null | grep -q module-echo-cancel; then
echo "✅ Echo cancellation module already loaded"
else
if pactl load-module module-echo-cancel source_name=aec_mic aec_method=webrtc; then
echo "✅ Echo cancellation enabled"
else
echo "⚠️ Failed to load echo cancellation module (continuing without it)"
fi
fi
AUDIO_INPUT_DEVICE="${AUDIO_INPUT_DEVICE:-aec_mic}"
fi


### Start application
if [ "$LIST_DEVICES" = "1" ]; then
echo "list input devices"
Expand Down
12 changes: 11 additions & 1 deletion docs/enabling_aec.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

Acoustic Echo Cancellation (AEC) is a type of sound processing used to cancel out the noise coming out of your speaker and going into your mic. In LVA this functionality can be useful to allow LVA to listen to wake words even when audio is playing, particularly when a timer is playing. PulseAudio and PipeWire already provide built-in modules for AEC.

## Enabling AEC
## Docker

Set `ENABLE_ECHO_CANCEL=1` in your `.env` file. The container will automatically load the PulseAudio AEC module and set `AUDIO_INPUT_DEVICE` to `aec_mic` at startup. If the module fails to load, a warning is logged and the application continues with the default audio devices.

```env
ENABLE_ECHO_CANCEL=1
```

For PipeWire or custom configurations, use the manual setup below and set `AUDIO_INPUT_DEVICE` directly.

## Manual Setup

### PulseAudio
```sh
Expand Down
Loading