I have used Audacity for removing noise from recordings before, however it has very limited command line usage. I have ~100 short lecture videos which I will be watching over the next few months and would like an easy way to clean them all at once or as needed before watching.

Is there a command line tool or popular language library I can use to do this?

3 Answers 3


The accepted answer doesn't give a practical example(see first comment to it) so I am trying to give one here. On Ubuntu with apt you should install sox and audio formats support


First install sox and support for formats (including mp3):

sudo apt install sox libsox-fmt-*

Then before you run your command on the file/files first you need to build a profile, make a sample of noise, this is the most important part you have to select the best time when the noise takes place, make sure you don't have voice (or the music/signal you try to keep) in this sample:

ffmpeg -i source.mp3 -ss 00:00:18 -t 00:00:20 noisesample.wav

Now make a profile out of that source:

sox noisesample.wav -n noiseprof noise_profile_file

And finally run the noise reduction on the file:

sox source.mp3 output.mp3 noisered noise_profile_file 0.31

Where noise_profile_file is the profile and 0.30 is the value. Values goes best somewhere between 0.20 and 0.30, over 0.3 is very aggressive, under 0.20 is kind of soft and works well for very noisy audios.

Try and play with that and if you find other setting tricks and please comment with the findings and tuning settings.

how to batch process them

If the noise is similar you can use the same profile for all the mp3 files

ls -r -1 *.mp3 | xargs -L1 -I{} sox {}  {}_noise_reduced.mp3  noisered noise_profile_file 0.31

or if there is a folder structure:

tree -fai . | grep -P ".mp3$" | xargs -L1 -I{} sox {}  {}_noise_reduced.mp3  noisered noise_profile_file 0.31
  • 1
    if it's spoken audio and separate left-right channels is unnecessary, then you can append remix - to mix-down of all input channels to mono Apr 21, 2019 at 13:03
  • 2
    @EduardFlorinescu Your answer is spot on. I had a static noise recording on the background of each recording. I read your answer and, used the first 2 seconds from my sound file to create a profile and finally, used it to remove the noise from the recording. Thanks so much for this. May 26, 2019 at 21:26
  • any solution to grab that noise profile automatically? I could imagine looking for quiet-ish parts of the track, but not sure how to do that via ffmpeg or sox Aug 12, 2020 at 20:37
  • @AlecJacobson That's the idea of the sample, the human is able to distinguish, if it were a program to be able to take the sample, it will also be able to take out the noise automatically, I think it can be done with AI but not with sox IMHO, I think it deserves a separate question Mar 11, 2021 at 22:23

Take a look at sox

Quoting man sox:

SoX - Sound eXchange, the Swiss Army knife of audio manipulation


SoX is a command-line audio processing  tool,  particularly  suited  to
making  quick,  simple  edits  and to batch processing.  If you need an
interactive, graphical audio editor, use audacity(1).

So, it should be a nice fit as a companion command line alternative to audaciy!

Regarding the actual task of cleaning recordings, take a look at the filter noisered for which equals the noise reduction filter Audacity:

man sox | less -p 'noisered \['

   noisered [profile-file [amount]]
           Reduce noise in the audio signal by profiling and filtering.
           This effect is moderately effective at  removing  consistent
           background  noise such as hiss or hum.  To use it, first run
           SoX with the noiseprof effect on a  section  of  audio  that
           ideally  would  contain silence but in fact contains noise -
           such sections are typically found at the  beginning  or  the
           end  of  a recording.  noiseprof will write out a noise pro‐
           file to profile-file, or to stdout if no profile-file or  if
           `-' is given.  E.g.
              sox speech.wav -n trim 0 1.5 noiseprof speech.noise-profil
           To  actually remove the noise, run SoX again, this time with
           the noisered effect; noisered will reduce noise according to
           a  noise  profile  (which  was generated by noiseprof), from
           profile-file, or from stdin if no profile-file or if `-'  is
           given.  E.g.
              sox speech.wav cleaned.wav noisered speech.noise-profile 0
           How  much  noise  should be removed is specified by amount-a
           number between 0 and 1 with a default of 0.5.   Higher  num‐
           bers will remove more noise but present a greater likelihood
           of removing wanted components of the audio  signal.   Before
           replacing  an  original  recording with a noise-reduced ver‐
           sion, experiment with different amount values  to  find  the
           optimal one for your audio; use headphones to check that you
           are happy with the results, paying particular  attention  to
           quieter sections of the audio.

           On  most systems, the two stages - profiling and reduction -
           can be combined using a pipe, e.g.
              sox noisy.wav -n trim 0 1 noiseprof | play noisy.wav noise
  • 7
    Unfortunately I find the description that sox uses in the manpage very noisy to read - pun intended. Is there not a much simpler way, with just one command alone to juggle around with noisereduction?
    – shevy
    Oct 16, 2015 at 20:15
  • Sure, no problem - just write in one simple sentence what you want to change - but precise enough to be technically clear... Ok, that will not work like this because you need to understand what noise is, and which of the parts of the noise you want to remove, which you may reduce, and what can reduce the sound quality otherwise doing the noise reduction. To juggle around with noise reduction, you need to know your juggling clubs - the kinds of noise to juggle, and how they can be balanced when they collide in mid air. Then, sox is your toolbox and first aid kit! Oct 16, 2015 at 23:14

Alternatively you could use an unattended approach. IMHO better due to the user claims that has 30h audio (probably lots of files to look for a part with only noise and no voice).

My approach:

  • Install rnnoise
  • Install denoiseit
  • Install ffmpeg (if needed)
  • Write a shell script (or adapt to your needs the one below):
for input_file in "$@"; do
    # Convert file to ".wav" 48k (needed by rnnnoise)
    ffmpeg -threads 2 -y -i "$input_file" -vn -ar 48000 "${file_name}.48k.wav"
    # Actual denoise
    denoiseit "${file_name}.48k.wav" "${file_name}.rnnoise.wav";
    # Convert to ogg
    ffmpeg -threads 2 -y -i "${file_name}.rnnoise.wav" "${file_name}.rnnoise.ogg"
    # Remove wav temporary files
    rm "${file_name}.48k.wav"
    rm "${file_name}.rnnoise.wav"

Usage from bash / your shell:

$ sh denoise.script.sh *.mp4
$ sh denoise.script.sh *.mp3
$ sh denoise.script.sh *.mkv
$ sh denoise.script.sh *.avi

Hope it helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .