I started reading a lot about PulseAudio and "hidden" options it had so I could find one that was similar to this question. The one I found was the noise-cancellation module, which is one that dramatically lowers any static noise on the microphone and even A LOT of the background noise, basically giving you the benefit of only recording your own voice with excellent quality (For audio recording for example). To do this follow this steps:
sudo nano /etc/pulse/default.pa
Add the following line anywhere on the file, but I recommend almost at the end where you will find a comment about Echo Cancellation stuff (~line 140):
load-module module-echo-cancel
Reload PulseAudio (pulseaudio -k) or simply restart the computer. You should be able to select the new Noise Cancellation option from the Input Device Section:
In this case I named the source logitechsource, but you can name it whatever you want and simply either restart pulseaudio.
Rename device
Lastly, if you do not want a super long name on the Sound Settings (When you want to select an input/output device). My suggestion is renaming the input device like this:
This is an old question, but I had the same problem and after some Googling (where I mostly found people who agreed it wasn't possible) and reading some man pages, I have now developed a solution based on user2330377's idea.
First you need to create a noise profile for SoX. Just use any audio recording program to record a few seconds of noise, then cd into the directory you saved it to and do sox noise.wav -n noiseprof noise.prof.
Then you need to create an ALSA loopback device:
sudo modprobe snd_aloop
This is required because pulseaudio, unlike Jack, cannot directly connect audio software together; we will hence use the loopback device as a proxy.
Now you need to start paman and find the names of both your microphone (or other recording device) and of the loopback device we just created. Once those are found, you can execute the following command to start recording sound from your microphone, piping it through SoX and then playing it on the loopback device:
pacat -r -d alsa_input.pci-0000_00_14.2.analog-stereo --latency=1msec|sox -b 16 -e signed -c 2 -r 44100 -t raw - -b 16 -e signed -c 2 -r 44100 -t raw - noisered noise.prof 0.2|pacat -p -d alsa_output.2.analog-stereo --latency=1msec
(Where you need to substitute the correct device names for the -d parameters -- the input device for the first pacat invocation and the loopback device output for the second.)
There you go, almost done! As a last step, start recording sound with the application of your choice, then start up pavucontrol, change to the "Recording" tab and set the audio device used for recording (displayed as the grey button to the right) to "Monitor of Loopback Audio Device". You should now have a clear and noise-free recording!
There is no any information on module documentation page about noise cancellation. There is only AEC (Acoustic Echo Cancellation) algorithm inside module-echo-cancel, which is have several implementations, like webrtc | speex.
Therefore you should buy headset|microphones with integrated noise cancellation feature as much as possible.
As I tested voice recording in ubuntu I found some particular qualities:
Skype, Telegram uses raw input from the default device (in my case front-in-mic|backward-mic jacks). If you need to cancel a noise in this apps, you should buys headsets|microphones only with integrated noise cancellation feature
If you need to use voice calls in browser, then you should keep in mind that browsers has it's own voice processing algorithms implementations, e.g. WebRTC.
Also web applications (sites like talky, hangouts, appear.in, etc) can have it's own voice processing algorithms implementations, despite the fact that they can be based on webrtc hangout-analysis
So simple solution on ubuntu LTS or debian based distros
this is an online script that activates noise cancellation feature that is already in pulse audio (the default audio on debian).
From the archive, copy the bin/ladspa/librnnoise_ladspa.so e.g. to /usr/local/lib/librnnoise_ladspa.so or anywhere else.
Find out the name of your input using pactl list sources short. For example my microphone is called alsa_input.usb-046d_0994_4A365E20-02.mono-fallback
Run the commands bellow to activate the noise cancellation (before running replace the /usr/local/lib/librnnoise_ladspa.so and alsa_input.usb-046d_0994_4A365E20-02.mono-fallback to your values determined in the steps 2. and 3.):
Investigation shows that there is no known way of doing real time noise reduction filtering with any Linux sub system. Some websites point to hardware you can buy which should do the trick much better than doing a software filter.
Alternatively if this is for a recording, you could pass the sound through Audacity and use the noise filter there.
webrtc-aec Yes Uses the webrtc.org AudioProcessing library for enhancing VoIP calls greatly in applications that support it by performing acoustic echo cancellation, analog gain control, noise suppression and other processing.
"We have presented rst results of a multi-channel noise/echo reduction solution built on
top of PulseAudio and motivated the design decisions. The work has resulted in a number of improvements in the PulseAudio echo cancellation and signal-processing framework,
which have been contributed during the version 3.0/4.0 development cycle and should facilitate future embedded Linux audio solutions. Further work includes optimizing code for audio stream mixing, more ecient resampling methods, and the implementation of an efficient AEC in the multi-channel processing pipeline."
Pulseaudio module
module-echo-cancel
I started reading a lot about PulseAudio and "hidden" options it had so I could find one that was similar to this question. The one I found was the noise-cancellation module, which is one that dramatically lowers any static noise on the microphone and even A LOT of the background noise, basically giving you the benefit of only recording your own voice with excellent quality (For audio recording for example). To do this follow this steps:
sudo nano /etc/pulse/default.pa
Add the following line anywhere on the file, but I recommend almost at the end where you will find a comment about Echo Cancellation stuff (~line 140):
Reload PulseAudio (
pulseaudio -k
) or simply restart the computer. You should be able to select the new Noise Cancellation option from the Input Device Section:You can find more information about it on the Echo Cancel Module Page
Set input as default
If you wish to set as default the echo cancel device simply turn the above line into:
and then at the bottom of the file add
In this case I named the source
logitechsource
, but you can name it whatever you want and simply either restart pulseaudio.Rename device
Lastly, if you do not want a super long name on the Sound Settings (When you want to select an input/output device). My suggestion is renaming the input device like this:
And again, restarting pulseaudio. The end result looks like this:
UPDATE - Full documentation Found Here Thanks to clément
This is an old question, but I had the same problem and after some Googling (where I mostly found people who agreed it wasn't possible) and reading some man pages, I have now developed a solution based on user2330377's idea.
First you need to create a noise profile for SoX. Just use any audio recording program to record a few seconds of noise, then
cd
into the directory you saved it to and dosox noise.wav -n noiseprof noise.prof
.Then you need to create an ALSA loopback device:
This is required because pulseaudio, unlike Jack, cannot directly connect audio software together; we will hence use the loopback device as a proxy.
Now you need to start
paman
and find the names of both your microphone (or other recording device) and of the loopback device we just created. Once those are found, you can execute the following command to start recording sound from your microphone, piping it through SoX and then playing it on the loopback device:(Where you need to substitute the correct device names for the -d parameters -- the input device for the first pacat invocation and the loopback device output for the second.)
There you go, almost done! As a last step, start recording sound with the application of your choice, then start up
pavucontrol
, change to the "Recording" tab and set the audio device used for recording (displayed as the grey button to the right) to "Monitor of Loopback Audio Device". You should now have a clear and noise-free recording!There is no any information on module documentation page about noise cancellation. There is only AEC (Acoustic Echo Cancellation) algorithm inside module-echo-cancel, which is have several implementations, like webrtc | speex.
Therefore you should buy headset|microphones with integrated noise cancellation feature as much as possible.
As I tested voice recording in ubuntu I found some particular qualities:
Skype, Telegram uses raw input from the default device (in my case front-in-mic|backward-mic jacks). If you need to cancel a noise in this apps, you should buys headsets|microphones only with integrated noise cancellation feature
If you need to use voice calls in browser, then you should keep in mind that browsers has it's own voice processing algorithms implementations, e.g. WebRTC.
Also web applications (sites like talky, hangouts, appear.in, etc) can have it's own voice processing algorithms implementations, despite the fact that they can be based on webrtc hangout-analysis
So simple solution on ubuntu LTS or debian based distros this is an online script that activates noise cancellation feature that is already in pulse audio (the default audio on debian).
you can also run these commands in secsetion (they are the same thing)
There is a noise suppression plugin for module-ladspa-sink:
Here you can can find a tutorial for installation on Fedora, and 2 sample recordings to get an idea about the effects of the plugin:
On Ubuntu:
bin/ladspa/librnnoise_ladspa.so
e.g. to/usr/local/lib/librnnoise_ladspa.so
or anywhere else.pactl list sources short
. For example my microphone is calledalsa_input.usb-046d_0994_4A365E20-02.mono-fallback
/usr/local/lib/librnnoise_ladspa.so
andalsa_input.usb-046d_0994_4A365E20-02.mono-fallback
to your values determined in the steps 2. and 3.):In your voice recording application you will configure audio input from
Null output
orRemapped monitor of null output
and test (I used Skype Echo)To make the changes permanent, append the commands from the step 4 into
/etc/pulse/default.pa
, omitting thepacmd
on the beginning of each line.Investigation shows that there is no known way of doing real time noise reduction filtering with any Linux sub system. Some websites point to hardware you can buy which should do the trick much better than doing a software filter.
Alternatively if this is for a recording, you could pass the sound through Audacity and use the noise filter there.
Here's at leas tone way, implement webrtc-aec in the
http://wiki.gentoo.org/wiki/PulseAudio
webrtc-aec Yes Uses the webrtc.org AudioProcessing library for enhancing VoIP calls greatly in applications that support it by performing acoustic echo cancellation, analog gain control, noise suppression and other processing.
Here's a paper dated 2013 on the subject (noise removal with pulseaudio not webrtc-aec specifically) http://lac.linuxaudio.org/2013/papers/37.pdf
"We have presented rst results of a multi-channel noise/echo reduction solution built on top of PulseAudio and motivated the design decisions. The work has resulted in a number of improvements in the PulseAudio echo cancellation and signal-processing framework, which have been contributed during the version 3.0/4.0 development cycle and should facilitate future embedded Linux audio solutions. Further work includes optimizing code for audio stream mixing, more ecient resampling methods, and the implementation of an efficient AEC in the multi-channel processing pipeline."
my amd laptop same problem the below code cancel my noise:
Hope someone will be helped
I use
NoiseTorch
in Arch Linux , is easy to use and easy to install => NoiseTorch Github Link