Pulse audio A module is included that can be used to perform echo cancellation on the microphone input and reduce some background noise. By default, most (if not all) Linux distributions do not enable this module, so this article will show you how to enable it.
I will show you two ways to enable the PulseAudio echo cancellation module: one to make it permanent so that it will automatically start when you log in to the desktop; the other allows you to enable echo cancellation as needed.
This not only provides two options, but also solves the PulseAudio problem. insect For example, this happens when the headset is plugged in after the “Echo Cancellation” module is loaded, which causes the problem to not automatically switch to the new
sink_master . Also, in my case, loading the module echo cancellation at startup does not work at all (I am not sure why), but it can be loaded without any problem after logging in using the second method below.
How to enable PulseAudio module at startup-echo cancellation
To always use PulseAudio to eliminate echo/noise on the Linux desktop and load the module echo cancellation function at startup, follow the steps below.
/etc/pulse/default.pa Use a text editor (such as Nano (command-line text editor)) as the root user:
sudo nano /etc/pulse/default.pa
Scroll down to the end of the file and paste the following:
.ifexists module-echo-cancel.soload-module module-echo-cancel aec_method=webrtc source_name=echocancel sink_name=echocancel1set-default-source echocancelset-default-sink echocancel1.endif
This is how it is done: If your system PulseAudio is compiled with the echo/noise cancellation module, please load the module, use webrtc as the echo cancellation method (it should be better than the default speex), specify the source and receiver names, Then set the source and sink to default values.
2. After saving the file, use the following command to reload PulseAudio:
Or restart the computer.
After that, check the sound settings of the system, the input and output devices should have default names, but “cancel echo with…” in parentheses, for example, “built-in audio analog stereo (use built-in cancellation echo) audio analog stereo)” , As shown in the screenshot at the top of the article.
This should persist after reboot.
If this doesn’t work for you, see the second method below to learn how to load module-echo-cancel on demand.
How to enable PulseAudio module to echo cancellation
To eliminate echo/noise via microphone input only when needed (by turning it on using the application menu item), follow the steps below.
1. Create a new file in your home folder named
echocancel Has the following content:
#!/usr/bin/env bashpactl unload-module module-echo-cancelpactl load-module module-echo-cancel aec_method=webrtc source_name=echocancel sink_name=echocancel1pacmd set-default-source echocancelpacmd set-default-sink echocancel1
This will unload the module -echo-cancel (if it’s already loaded), then use webrtc as the echo cancellation method (should be better than the default speex) to load this module, specify the source and sink names, and then set the source and sink to Defaults.
2. After saving the file, make it executable and copy it to a location in the path.You can make it executable and place it in
/usr/local/bin Use this command:
sudo install echocancel /usr/local/bin
3. Create a file named
echocancel.desktop In your home folder, it contains the following:
[Desktop Entry]Version=1.0Name=Echo Cancel PulseAudio ModuleComment=Load the PulseAudio module-echo-cancelExec=echocancelIcon=multimedia-volume-controlType=ApplicationCategories=AudioVideo;Audio;
4. Save the file and copy it to
~/.local/share/applications/ , For example, use the following command to do this from the command line:
cp echocancel.desktop ~/.local/share/applications/
You should now see a file called
Echo Cancel PulseAudio Module In your application menu. When you click it, it should load the PulseAudio volume of echo/noise reduction.
After running this command, check the sound settings of the system. Both the input and output devices should have default names, but should have “echo canceled with …” in parentheses, as shown in the screenshot at the top of this article.
If you want to uninstall the PulseAudio module of echo cancellation, you can run:
pactl unload-module module-echo-cancel
For more information, see PulseAudio Module echo cancellation document .