Remove silence from audio files while leaving gaps

14,908

The best way that I've seen is by adding the -l flag to silence as follows:

sox in.wav out6.wav silence -l 1 0.1 1% -1 2.0 1%

I've copied this command from Example 6 of this very useful blog post called The Sox of Silence

Share:
14,908

Related videos on Youtube

Nathan Arthur
Author by

Nathan Arthur

Updated on September 18, 2022

Comments

  • Nathan Arthur
    Nathan Arthur over 1 year

    Currently we're using this command within a shell script to remove silence from audio files:

    ffmpeg -i $INFILE -af silenceremove=0:0:0:-1:1:${NOISE_TOLERANCE}dB -ac 1 $SILENCED_FILE -y
    

    This works fine except that it removes all the silence, causing the remaining audio to be squeezed together.

    How can this be done while leaving two or three seconds between each piece of audio?

    The solution needs to be very efficient as we'll be processing a lot of audio and should use a tool that can be fairly easily installed on both Linux and OSX, such as ffmpeg or sox.

  • zero_cool
    zero_cool about 5 years
    I'd like to do this for a video and trim the silence - will SoX work? What is the best alternative?