Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using Sox (http://sox.sourceforge.net) to remove background noise and/or silence from audio files (individually, or in batch).
# Create background noise profile from mp3
/usr/bin/sox noise.mp3 -n noiseprof noise.prof
# Remove noise from mp3 using profile
/usr/bin/sox input.mp3 output.mp3 noisered noise.prof 0.21
# Remove silence from mp3
/usr/bin/sox input.mp3 output.mp3 silence -l 1 0.3 5% -1 2.0 5%
# Remove noise and silence in a single command
/usr/bin/sox input.mp3 output.mp3 noisered noise.prof 0.21 silence -l 1 0.3 5% -1 2.0 5%
# Batch process files
/usr/bin/find . -type f -name "*.mp3" -mmin +30 -exec sox -S --multi-threaded -buffer 131072 {} /path/to/output/{} noisered noise.prof 0.21 silence -l 1 0.3 5% -1 2.0 5% \;
# Remove insignificant files
/usr/bin/find . -type f -name "*.mp3" -mmin +30 -size -500k -delete
@theonlygusti

This comment has been minimized.

Copy link

theonlygusti commented Sep 25, 2017

How can I control the amount of noise that it is reduced by?

@theonlygusti

This comment has been minimized.

Copy link

theonlygusti commented Sep 27, 2017

@david-treblig

This comment has been minimized.

Copy link

david-treblig commented Oct 8, 2017

@theonlygusti It is by changing the number right after "noise.prof" (currently, in this example, it is 0.21). You can learn more about the sox command line here : http://sox.sourceforge.net/sox.html#EFFECTS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.