ganzgustav22
Posts: 234
Joined: Tue Feb 11, 2020 1:04 pm

pulseaudio Acoustic Echo Canceller working with OS release 2021-01-11, yay

Thu Feb 04, 2021 11:15 am

Just wanted to let people know, that with the new Raspberry Pi OS version 2021-01-11, the pulseaudio echo cancellation module now works perfect (with the 2020-05-27 release it wouldn't work very good).

If anybody is interested to get it working, simply put this at the end of /etc/pulse/default.pa

Code: Select all

load-module module-echo-cancel source_name=aec_source source_properties=device.description=aec_source sink_name=aec_sink sink_properties=device.description=aec_sink aec_method=webrtc channels=1

set-default-source aec_source
set-default-sink aec_sink
Then reboot. Then enjoy echo-free communication.

bls
Posts: 1582
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: pulseaudio Acoustic Echo Canceller working with OS release 2021-01-11, yay

Thu Feb 04, 2021 2:27 pm

Thanks for sharing this. I was pleasantly surprised to find that my very basic testing of sound on 2021-01-11 worked right out of the box. Great to hear that there are other improvements as well.
Pi tools:
Quickly and easily build customized-just-for-you SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

0n3man
Posts: 4
Joined: Tue May 11, 2021 7:16 pm

Re: pulseaudio Acoustic Echo Canceller working with OS release 2021-01-11, yay

Tue May 11, 2021 7:56 pm

Just enabled this feature however it's hard to tell if it's working. From online documentation it appears other distros annotated the micro in the GUI to indicate AEC is enabled. That doesn't happen on my raspberry pi os system. Any suggestions on how to verify this is working? Thanks

0n3man
Posts: 4
Joined: Tue May 11, 2021 7:16 pm

Re: pulseaudio Acoustic Echo Canceller working with OS release 2021-01-11, yay

Wed May 12, 2021 2:37 am

I did some recording with aec on and off. Also found some information on arguments and added in aec_args="drift_compensation=1\ voice_detection=1" as they seemed like arguments that could provide improvements. It didn't appear to have an impact, but it's possible they should have an impact. Any suggestions would be appreciated.

0n3man
Posts: 4
Joined: Tue May 11, 2021 7:16 pm

Re: pulseaudio Acoustic Echo Canceller working with OS release 2021-01-11, yay

Sat May 15, 2021 1:43 am

It seems the voice_detection parameter simply tags the data when voice is detected and thus isn't helpful for what I was trying to do.

0n3man
Posts: 4
Joined: Tue May 11, 2021 7:16 pm

Re: pulseaudio Acoustic Echo Canceller working with OS release 2021-01-11, yay

Sun May 16, 2021 11:48 am

When I was doing my testing the amplitude of the resulting signal was very low. Is this expected? Are their any configuration suggestion to ensure reasonable signal level going in and coming out the microphone AEC algorithm?

mangodan2003
Posts: 66
Joined: Thu Apr 23, 2015 1:10 pm

Re: pulseaudio Acoustic Echo Canceller working with OS release 2021-01-11, yay

Fri Jun 04, 2021 3:52 pm

Does anybody still have this working? I have just tried with the 2021-05-07 release and it doesn't seem to work, at least not with the hardware I am using.
I have seen statements (but I think all very old) that the source and sample rates must match, which makes sense, it would certainly seem a lot easier to cancel echo on streams that are running at the same rate. It seems the module (or pulseaudio itself I am not sure which to be honest) handles trying to make them match, it states it is running at 32kHz, where as my source mic is 16kHz and the speaker DAC is running at 44.1kHz. I am suspecting that inaccuracies in the conversion is leading to drifts, and I have no idea how it tries to make sure they match when a given source or sink will never run at exactly the rate it is intended to, maybe it compares them both with a system timer, I don't know.

I have also tried with drift_compensation=1 but this did not seem to help. There are various other options such as setting "mobile=true routing_mode=speakerphone" but this did not seem to help either.

So my question really is for anyone who has a working setup, are the source and sink from the same hardware device (clocked at the same rate) or have you got it working with separate source and sinks such as USB mic and separate USB DAC?

I tried and found that the echo cancellation built into chrome (from which aec_method=webrtc is derived) seems to work just fine with my hardware.

mangodan2003
Posts: 66
Joined: Thu Apr 23, 2015 1:10 pm

Re: pulseaudio Acoustic Echo Canceller working with OS release 2021-01-11, yay

Wed Jun 09, 2021 9:11 am

Having tried this on my desktop PC using the internal sound card with both input and output on the same device it works very well.
Having tried the USB devices I was using on the raspberry pi on the same desktop PC it initially did not work. I tried setting the rate for the echo-cancel module to 48kHz instead of the default 32. At this rate it worked! I tried the same on the RPi and it seems to still not work but I was running out of time so will revisit this soon.

Return to “Graphics, sound and multimedia”