Skip to content

Instantly share code, notes, and snippets.

@mauron85
Last active March 11, 2022 15:07
Show Gist options
  • Save mauron85/fdb1440cb7908f46898a525901c91dbc to your computer and use it in GitHub Desktop.
Save mauron85/fdb1440cb7908f46898a525901c91dbc to your computer and use it in GitHub Desktop.
How to record and filter noise from mic in Linux
# Useful links
# https://stackoverflow.com/questions/42904441/pipe-sox-play-command-to-stdout
# http://www.zoharbabin.com/how-to-do-noise-reduction-using-ffmpeg-and-sox/
# Record some noise
sox -t alsa default -b 16 -r 44100 -e signed -t wav - -t wav /tmp/noise.wav
# or alternative with arecord
arecord -f dat | sox -t wav -b 16 -r 44100 -e signed - -t wav /tmp/noise.wav
# Profile noise
sox /tmp/noise.wav -n noiseprof /tmp/noise.prof
# Play with filtered noise
arecord -f dat | sox -t wav -b 16 -r 44100 -e signed - -t wav - noisered /tmp/noise.prof 0.21 | play -
@Manawyrm
Copy link

Thanks! If someone else finds this: -f dat runs at 48kHz, so you need to change the sox command to -f 48000!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment