How to batch split audio files wherever there is silence?
Asked Answered
J

3

25

I am using the following command in SoX to split many large audio files at each place where there is silence longer than 0.3 seconds:

sox -V3 input.wav output.wav silence 1 0.50 0.1% 1 0.3 0.1% : newfile : restart

This however ends up occasionally creating files that are entirely silent and trimming the audio before each break.

I found better results with Audacity, but I need to split hundreds of WAV files and Audacity cannot even open 10 files simultaneously without freezing.

How can I use SoX or similar software to split the files at the end of the 0.3 second periods of silence, such that the silent portion is still affixed to the end of the speaking, but not before and there are no clips that are entirely silent, unless they come from the beginning of input.wav?

Jeremy answered 16/11, 2013 at 2:55 Comment(2)
Use sox $wav -n stat and look at Mean norm value. For silent files it will be < 0.01. Use this logic and discard all silent files.Damalas
for me no of the solution workInfancy
C
15

if you change 0.5 to 3.0, it works fine:

sox -V3 input.wav output.wav silence 1 3.0 0.1% 1 0.3 0.1% : newfile : restart
Covert answered 15/8, 2015 at 10:53 Comment(2)
Please explain the parameters in your answer.Erlking
@Covert what do the params mean?Trumaine
S
9

You didn't specify any programming language, so I assume that you're not especially looking for a way to program it yourself (which makes it a bit off-topic here). It wouldn't be very hard to do by the way.

Anyway, maybe this does the trick for you:

http://www.nch.com.au/splitter/

You can set a threshold in dB to split. I guess that when you set it to 0dB, you'll get all the audio that you need per slice.

Stepper answered 14/3, 2014 at 8:30 Comment(1)
Not anymore. I just went to the site and there's a macOS version.Clemenceau
I
5
sox -V3 orig.wav p.wav silence -l  0   1 0.5 0.1% : newfile : restart

this works for me. I found some useful explanations on the command here and here.

Infancy answered 26/2, 2017 at 8:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.