SoX: How to Remove Background Noise

Updated

Learn how to remove background noise from audio using SoX

SoX: How to Remove Background Noise

Before we start, make sure you have SoX installed on your computer and your noisy audio file ready in a folder. On a Mac, you can install it with Homebrew:

brew install sox

Create a Noise Profile

First, open your terminal and navigate to the folder with your audio file using cd. SoX needs a sample of just the background noise, so pick a second or so at the start of your file with no music or voice in it. To create the noise profile, run this command:

sox input.wav -n trim 0 1 noiseprof noise.prof

Here, -n tells SoX not to write an audio file, trim 0 1 grabs the first second, and noiseprof saves its noise fingerprint to noise.prof. Just make sure that sample has no music or speech in it, or SoX will remove those sounds from your audio too.

Remove the Noise

Now apply the profile to the whole file with the noisered effect:

sox input.wav output.wav noisered noise.prof 0.21

Just remember to replace input.wav with your actual file name. The 0.21 value sets how strong the reduction is. Stay between 0.2 and 0.3, because going higher can make the audio sound metallic. For a short clip, this finishes almost instantly, and don't worry if you don't see a success message.

To make sure everything worked, run play output.wav to listen to the cleaned file right from your terminal.

undefined

If your audio also has low rumble, like an air conditioner or traffic, just add highpass 100 before noisered to cut the low frequencies too:

sox input.wav output.wav highpass 100 noisered noise.prof 0.21