Back to Noise Suppression For Voice

README

README.md

1.2114.3 KB
Original Source
<h1 align="center" style="line-height:0;">Real-time Noise Suppression Plugin</h1> <h2 align="center" >VST2, VST3, LV2, LADSPA, AU, AUv3</h2> <div align="center">

<a href=""></a> <a href=""></a>

</div>

A real-time noise suppression plugin for voice based on Xiph's RNNoise. More info about the base library.

The plugin is meant to suppress a wide range of noise origins (from original paper): computer fans, office, crowd, airplane, car, train, construction.

From my tests mild background noise is always suppressed, loud sounds, like clicking of mechanical keyboard, are suppressed while there is no voice however they are only reduced in volume when voice is present.

Please note that this plugin could not improve the voice quality with bad microphone, it even could make things worse by misclassifying the voice as a noise which would reduce already not-so-good voice quality.

The plugin works with one or more channels, 16 bit, 48000 Hz audio input.

:exclamation: :exclamation: :exclamation: Do NOT use any other sample rates, use ONLY 48000 Hz, make sure your audio source is 48000 Hz and force it to be 48000 Hz if it is not.

There is a minimalistic GUI with all parameters and diagnostic stats:

<div align="center"> </div>

Releases

Latest releases

How-to

Plugin Settings

  • VAD Threshold (%) - if probability of sound being a voice is lower than this threshold - it will be silenced. Valid range is 0..100%; the default and recommended starting point is 85%. Higher values are stricter. In most cases the threshold between 85% - 95% would be fine. Without the VAD some loud noises may still be a bit audible when there is no voice.
  • VAD Grace Period (ms) - for how long after the last voice detection the output won't be silenced. This helps when ends of words/sentences are being cut off.
  • Retroactive VAD Grace Period (ms) - similar to VAD Grace Period (ms) but for starts of words/sentences. :warning: This introduces latency!
  • Mix - dry/wet blend for VST/VST3/LV2/AU/AUv3. 0 is dry input only, 1 is fully processed output.
  • Dry Mix - LADSPA-only, how much of dry input is mixed in. To keep backwards config compatibility - 0 is wet, 1 is dry.

Windows + Equalizer APO (VST2)

Download Equalizer APO from equalizerapo.com or the SourceForge project.

Install Equalizer APO and configure it for the microphone device you want to process. During setup, select the target microphone in the Equalizer APO Configurator and reboot if the installer asks for it. You can check or change microphone settings in Windows through "Recording devices" -> "Recording" -> "Properties" of the target mic -> "Advanced".

After reboot, open Equalizer APO Configuration Editor. To enable the plugin select "Plugins" -> "VST Plugin", choose the RNNoise VST DLL, and adjust VAD threshold, grace periods, and mix in the plugin GUI.

See detailed guide provided by @bssankaran.

Linux

PipeWire

Since version 0.3.45 PipeWire uses Split-File Configuration, making it extremely easy to set up plugins and tweak configuration.

For older PipeWire version you'd have to copy /usr/share/pipewire/pipewire.conf into ~/.config/pipewire/pipewire.conf and then append the configuration below to already existing context.modules.

For PipeWire >= 0.3.45 you should:

  • Create config directory: ~/.config/pipewire/pipewire.conf.d/
  • Create config for plugin: ~/.config/pipewire/pipewire.conf.d/99-input-denoising.conf
  • Paste configuration:
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 = librnnoise_ladspa
                    label = noise_suppressor_mono
                    control = {
                        "VAD Threshold (%)" = 85.0
                        "VAD Grace Period (ms)" = 200
                        "Retroactive VAD Grace (ms)" = 0
                        "Dry Mix" = 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
        }
    }
}
]
  • Make sure librnnoise_ladspa.so is installed in a LADSPA plugin search path, for example /usr/lib/ladspa/ or /usr/lib64/ladspa/. Recent PipeWire versions resolve LADSPA plugins by name from the LADSPA search path and do not accept arbitrary absolute .so paths outside that path.
  • If you are absolutely sure that you need stereo output - change noise_suppressor_mono -> noise_suppressor_stereo. Even if your mic says that it is stereo - you probably don't need stereo output. It also would consume 2x resources.
  • Configure plugin parameters: VAD Threshold (%), VAD Grace Period (ms), Retroactive VAD Grace (ms), and optionally Dry Mix.
  • Restart PipeWire: systemctl restart --user pipewire.service
  • Now you should be able to select Noise Canceling source as input device

For more information consult PipeWire documentation on Filter-Chains

Troubleshooting:

  • TODO, how to change sample rate for mic.

Alternative solutions for PipeWire/PulseAudio configuration which also use RNNoise:

  • EasyEffects - a general solution for audio effects GUI for PipeWire. Easy to set up and use. Fewer settings for denoising. Available on Flathub.
  • NoiseTorch - easy to set up, works with PulseAudio and Pipewire. Fewer settings for denoising.

PulseAudio

TLDR: Use PipeWire... or follow the instructions below.

<details> <summary>Instructions (click me)</summary>

The idea is:

  • Create a sink from which apps will take audio later and which will be the end sink in the chain.
  • Load the plugin which outputs to already created sink (sink_master parameter) and has input sink (sink_name parameter, sink will be created).
  • Create loopback from microphone (source) to input sink of plugin (sink) with 1 channel.

For example, to create a new mono device with noise-reduced audio from your microphone, first, find your mic name using e.g.:

sh
pactl list sources short

Then, create the new device using:

sh
pacmd load-module module-null-sink sink_name=mic_denoised_out rate=48000
pacmd load-module module-ladspa-sink sink_name=mic_raw_in sink_master=mic_denoised_out label=noise_suppressor_mono plugin=/path/to/librnnoise_ladspa.so control=85,20,0,0,0
pacmd load-module module-loopback source=<your_mic_name> sink=mic_raw_in channels=1 source_dont_move=true sink_dont_move=true

This needs to be executed every time PulseAudio is launched. You can automate this by creating file in ~/.config/pulse/default.pa with the content:

.include /etc/pulse/default.pa

load-module module-null-sink sink_name=mic_denoised_out rate=48000
load-module module-ladspa-sink sink_name=mic_raw_in sink_master=mic_denoised_out label=noise_suppressor_mono plugin=/path/to/librnnoise_ladspa.so control=85,200,0,0,0
load-module module-loopback source=your_mic_name sink=mic_raw_in channels=1 source_dont_move=true sink_dont_move=true

set-default-source mic_denoised_out.monitor

The order of settings in control=85,200,0,0,0 is: VAD Threshold (%), VAD Grace Period (ms), Retroactive VAD Grace Period (ms), Placeholder1, Dry Mix.

If you are absolutely sure that you want a stereo input use these options instead:

  • label=noise_suppressor_stereo
  • channels=2

If you have problems with audio crackling or high / periodically increasing latency, adding latency_msec=1 to the loopback might help:

load-module module-loopback source=your_mic_name sink=mic_raw_in channels=1 source_dont_move=true sink_dont_move=true latency_msec=1

:warning: Chrome and other Chromium based browsers will ignore monitor devices and you will not be able to select the "Monitor of Null Output". To work around this, either use pavucontrol to assign the input to Chrome, or remap this device in PulseAudio to create a regular source:

sh
pacmd load-module module-remap-source source_name=denoised master=mic_denoised_out.monitor channels=1

You may still need to set correct input for application, this can be done in audio mixer panel (if you have one) in 'Recording' tab where you should set 'Monitor of Null Output' as source.

Further reading:

  • Useful detailed info about PulseAudio logic toadjaune/pulseaudio-config.
  • The thread which helped me with how to post-process mic output and make it available to applications.
</details>

macOS

The macOS release archive contains the plug-in bundles under bin. For most hosts, install one of these:

  • rnnoise.vst3 - VST3 plug-in. Copy it to ~/Library/Audio/Plug-Ins/VST3/ for your user, or /Library/Audio/Plug-Ins/VST3/ for all users.
  • rnnoise.component - Audio Unit plug-in. Copy it to ~/Library/Audio/Plug-Ins/Components/ for your user, or /Library/Audio/Plug-Ins/Components/ for all users.
  • rnnoise_mono.vst and rnnoise_stereo.vst - VST2 plug-ins. Copy them to ~/Library/Audio/Plug-Ins/VST/ for your user, or /Library/Audio/Plug-Ins/VST/ for all users.

Create the destination directory if it does not exist, then restart the host application or rescan plug-ins in the host's plug-in manager.

Use the format your host supports. Logic Pro, GarageBand, and MainStage use Audio Units. REAPER and many other DAWs can use VST3, VST2, and/or Audio Units.

If macOS blocks a downloaded plug-in, first try opening the host once and approving the plug-in in System Settings -> Privacy & Security. If that is not enough and you trust the downloaded archive, remove the quarantine attribute from the copied bundle:

sh
xattr -dr com.apple.quarantine ~/Library/Audio/Plug-Ins/VST3/rnnoise.vst3

If you build from source on macOS, the release workflow builds universal x86_64/arm64 plug-ins. A local build on Apple Silicon or Intel will use the architecture selected by CMake unless you set CMAKE_OSX_ARCHITECTURES.

Status

The plugin is tested with:

  • Equalizer APO v1.2 x64 (open source system-wide equalizer for Windows)
  • PipeWire on Arch Linux
  • Carla (on Linux)
  • Audacity (on Linux)

I'm not associated with the original RNNoise work and do NOT have any understanding of recurrent neural networks it is based upon.

Audio evaluation tool

<details> <summary>Dataset setup and usage</summary>

An optional rnnoise_audio_eval executable can run the common processor against paired clean/noisy speech samples and save processed WAVs for manual listening.

Download the small Edinburgh test archives into a local data directory, for example test-data/:

Build the tool:

sh
cmake -S . -B build-audio-eval -DBUILD_AUDIO_EVAL_TOOL=ON
cmake --build build-audio-eval --target rnnoise_audio_eval -j 8

Run the evaluation:

sh
./build-audio-eval/src/common/rnnoise_audio_eval \
  --data-dir test-data \
  --output-dir build-audio-eval/audio-eval/processed \
  --jobs 8

The tool accepts either the ZIP files above or already extracted clean_testset_wav/ and noisyreverb_testset_wav/ directories. It prints SNR lift, quiet-region attenuation, chunk-size consistency, and retroactive VAD stats. Representative clean/noisy/processed WAVs are written to --output-dir; pass --write-all to save every processed clip.

</details>

Contributing

External dependencies are vendored via git-subrepo. So that there is no need to use submodules, and patching subrepos is easy (at the moment we have several patches for JUCE).

Improvements are welcomed! Though if you want to contribute anything sizeable - open an issue first.

Compiling

Compiling for x64:

sh
cmake -Bbuild-x64 -H. -GNinja -DCMAKE_BUILD_TYPE=Release
ninja -C build-x64

Compiling for x32:

sh
cmake -D CMAKE_CXX_FLAGS=-m32 -D CMAKE_C_FLAGS=-m32 -Bbuild-x32 -H. -GNinja -DCMAKE_BUILD_TYPE=Release
ninja -C build-x32

Cross-compiling for Windows x64 (MinGW builds are failing at the moment due to certain incompatibilities in JUCE):

sh
cmake -Bbuild-mingw64 -H. -GNinja -DCMAKE_TOOLCHAIN_FILE=toolchains/toolchain-mingw64.cmake -DCMAKE_BUILD_TYPE=Release
ninja -C build-mingw64

Compiling only selected plugins

By default, all plugins supported for a platform are being built. You can deliberately turn off plugins with the following CMake flags:

  • BUILD_LADSPA_PLUGIN
  • BUILD_VST_PLUGIN
  • BUILD_VST3_PLUGIN
  • BUILD_LV2_PLUGIN
  • BUILD_AU_PLUGIN (macOS only)
  • BUILD_AUV3_PLUGIN (macOS only)

For example:

sh
cmake -DBUILD_VST_PLUGIN=OFF -DBUILD_LV2_PLUGIN=OFF

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

Used libraries: