This is a followup to request 1932425 'split on silence' where it was shown how to split on silence while recording music. I was asked to submit a more specific usecase if I had one--here goes.
I want to split existing .wav files that contain speech. I want a minimum duration between silences before splitting because in theory there could be silence between every word or sentence. If I can specify a minimum of five minutes, I can split an hours worth of speech into 10-12 tracks which makes skipping convenient for the listener.
Thanks
I have a very similar need/usecase when splitting audio streams into songs. Sometimes the silence effect will detect false positives to early in the song (same issue as silence between words). The following is my solution but geared towards your usecase.
sox infile.wav outfile.wav trim 0 5:00 : silence 0 1 2.0 0.1% : newfile : restart
The above will always read 5 minutes worth of audio data without doing any silence detection and copy to output file. This is the 5 minutes minimum part you requested.
After that point, it will look for 2.0 seconds worth of silence as a break point. Once found, it will move on to create a new output file and then restart the process all over again by copying 5 minutes worth of audio data. And so on until end-of-file is reached on input.
Depending on how you will use the split audio files, the "-l" option for silence effect may be of interest. If added to above command line, it should always leave the 2 seconds of silence to beginning of each new file (but no more then 2 seconds). This is useful if playing split files back-to-back so that voices don't run together at the transition point.
FYI: The "-l" (along with negative "below_periods") was originally created by someone that wanted to remove long pauses in recordings of conversations to speed up the playback. Unfortunately, that feature is incompatible with above command line feature so you'd have to make a second run on each file that's split up to remove long pauses.
The above syntax, of course, requires at least 14.2.0-rc1 version of SoX to work.