need to clean up audio noise using sox

3

What I am doing right now is recording audio from my mic using arecord and piping the raw output to VLC like so:

arecord -r 8000 - | vlc -vvv - 

It works great, except the audio that is coming out has a lot of noise. I know it is possible to clean up background noise using sox, but I can't seem to figure out the right commands. When I use "play" just to test output (without even attempting noise removal), the output sounds horrible using:

play -t raw -b 16 -c 1 -e signed -r 8000 -

Are there any other solutions other than sox/play? If I can do this via VLC itself, that would be ideal. I also need to amplify the sound as well, which is why I use VLC. If I can get sox to clean up the audio and the pipe the output back to VLC again, that would be amazing. How could I accomplish this, I am sure it's possible.

My goals are to (1) clean all the background noise and (2) amplify the audio as much as possible.

eagleon

Posted 2013-04-28T15:00:47.480

Reputation: 31

I don't know anything about the system you are using, but loud background noise suggests that the signal to noise ratio at the 1st stage is too small. Recording by microphone is prone to this. Can you not get a direct signal rather than use that mic? – Xavierjazz – 2013-04-28T15:33:14.943

thanks for the response Xavierjazz, im using ubuntu linux, the hardware is a laptop and I need to be able to do this on the move without any special equipment at the moment. The laptop FAN is among the noise makers, but even when that is not running, there is still a lot of noise even in a dead quiet room. :-( – eagleon – 2013-04-28T15:37:18.367

I should mention, the audio sounds great using VLC except for the background noise. I can hear a lot of subtle things... so if I were able to remove this static sound in the background, I would have a pretty crisp output. – eagleon – 2013-04-28T15:54:22.580

Well, I would try try Audacity or something similar: http://wiki.audacityteam.org/wiki/Noise_Removal

– Xavierjazz – 2013-04-28T16:43:59.983

1make your mic more directional – Ruskes – 2013-04-28T16:53:01.530

Thanks for the suggestions, appreciate it. Xavierjazz, Is it possible to use Audacity through a piped output? I tried Audacity already and the results weren't too impressive. Buscar, the mic is built in to the laptop. Not sure if this is possible. -- I want to try this out on sox, but I just can't get the right flag sequence... I need to pipe it from arecord to sox (apply the noise filter) and then pipe out again to vlc.. I think that would work, but I don't know how to pipe it that way. – eagleon – 2013-04-28T19:22:26.717

Answers

5

Here is a bash script to fix up vocal audio with sox:

#!/bin/sh                                                                                                                                

# This script shows using several
# effects in combination to normalise and trim voice recordings that                                                                   
# may have been recorded using different microphones, with differing                                                                   
# background noise etc.                                                                                                                   

SOX=/usr/bin/sox

if [ $# -lt 2 ]; then
  echo "Usage: $0 infile outfile"
  exit 1
fi

$SOX "/tmp/tmp_audio_leveled.wav" -n trim 0 0.5  noiseprof newprofile
$SOX "/tmp/tmp_audio_leveled.wav" $2 noisered newprofile

$SOX "$1" "/tmp/tmp_audio_leveled.wav" \
    remix - \
    highpass 100 \
    norm \
    compand 0.05,0.2 6:-54,-90,-36,-36,-24,-24,0,-12 0 -90 0.1 \
    vad -T 0.6 -p 0.2 -t 5 \
    fade 0.1 \
    reverse \
    vad -T 0.6 -p 0.2 -t 5 \
    fade 0.1 \
    reverse \
    norm -0.5 `                                                                                                        

frazras

Posted 2013-04-28T15:00:47.480

Reputation: 151