Reducing microphone noise using pipewire modules
With pulseaudio, it was easy to load a module for microphone noise reduction.
This link explains it clearly:
https://askubuntu.com/questions/18958/realtime-noise-removal-with-pulseaudio
I want to add rnnoise as a plugin of pipewire to cancel the noise of the microphone for all users.
I’m looking for a minimalist solution and would like to avoid applications. Like this one:
https://github.com/noisetorch/NoiseTorch?tab=readme-ov-file
Install noise-suppression-for-voice. As of April 2024, there’s no Ubuntu package, see this open issue for installation instructions. It is packaged for Arch, Alpine, Gentoo, and openSUSE, though. See its README for settings you can tweak.
I have found a way to load rnnoise
as a pipewire
plugin for all users.
Step 1:
On this page you can download the rnnoise
drivers compiled for X86 linux. This is not the last version of rnnoise
. If you want the latest version, i think you have to perform compilation by yourself from the official github repo.
Step 2:
In the downloaded archive, you will find the needed linux libs.
Always take mono libs. You probably have only one microphone!
I propose to store them in /usr/lib/audio/
So you will have to create the folder audio.
As i renamed the files, i have now in this folder:
- ladspa.so
- lv2.so
- vst3.so
- vst.so
Step 3
Create the 2 pipewire
folders to get this path:
/etc/pipewire/pipewire.conf.d/
Step 4
In this folder create the file 99-mic-denoising.conf
.
In this file paste this content:
context.modules = [
{name = libpipewire-module-filter-chain
args = {
node.description = "Noise Canceling source"
media.name = "Noise Canceling source"
filter.graph = {
nodes = [
{
type = ladspa
name = rnnoise
plugin = /usr/lib/audio/ladspa.so
label = noise_suppressor_mono
control = {
"VAD Threshold (%)" = 90.0
"VAD Grace Period (ms)" = 200
"Retroactive VAD Grace (ms)" = 0
}
}
]
}
capture.props = {
node.name = "capture.rnnoise_source"
node.passive = true
audio.rate = 48000
}
playback.props = {
node.name = "rnnoise_source"
media.class = Audio/Source
audio.rate = 48000
}
}
}
]
Step 5
Restart pipewire deamon:
systemctl restart --user pipewire.service
Now in gnome settings you can choose the microphone with noise cancelled.
Comments
- We so use the pipewire filter-chain module. Check the documentation, it’s very useful.
- Each application (which use audio) has been designed to use a standard (called audio plugin API):
- ladspa: open standard…but it’s not the newest one
- lv2: open standard…the newest one
- vst3: proprietary standard (you should not see it with open source programs)
- vst: proprietary standard (you should not ….)
So the solution I provided, doesn’t cover applications using lv2 audio plugin (i don’t care about proprietary standards). Any help for lv2 is welcome.