Search code examples
audiosoxfilesplitting

Split audio file but only in pauses


I've been playting around with sox and using the trim command it should be fairly simple to split the whole audio into n parts (with a fixed length per part).

However as I intend to split spoken recordings it might happen that a simple splitting will split in the middle of a word.

Is there a way to prevent that and make sure that parts contain "whole words"?


Solution

  • Take a look at the sox silence command on the (archived) sox webpage for manual and Sound eXchange on sourceforge.

    sox original.wav new.wav silence 1 0.5 2% 1 2.0 2% : newfile : restart
    

    Parameters:

    original.wav - the audio file to be spliced.

    new.wav - will be the name of the new audio files with numbers appended to each slice (new1.wav, new2.wav, new3.wav...).

    silence - name of the effect.

    1 0.5 2% - above_periods, duration, threshold.

    1 2.0 2% - below_periods, duration, threshold.