Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripping silence with sox

Tags:

sox

I have around 20,000 .wav files (all voice lines) that I need to strip the silence from the start AND end of.

The "silence" isn't pure silence, so I'll need to set a threshold.

I'd also like to leave a little "silence" before the actual sound/voice starts, so each file would get trimmed but .X seconds of the original silence remains.

I've tried various commands and can't get it to set a threshold correctly. I've seen a lot of internet comments about doing this, so I must be using the command wrong.

I also can't figure out how to leave .X seconds of silence.

I assume sox can do this, or at least most of it?

like image 551
Roger Gilbrat Avatar asked Dec 21 '16 23:12

Roger Gilbrat


2 Answers

I found this very useful guide for using SoX Silence. While the official SoX Silence manual page is quite a mess and incomprehensible, this guide provides thorough explanation with examples: https://digitalcardboard.com/blog/2009/08/25/the-sox-of-silence/comment-page-2/

You can try:

sox input.wav output.wav silence 1 X 0.1% 1 X 0.1% : newfile : restart

with X being a number such as 0.75

like image 118
Kid_Learning_C Avatar answered Sep 29 '22 13:09

Kid_Learning_C


Trim the silence beginning of the audio

sox in.wav out1.wav silence 1 0.1 1%

Source: https://digitalcardboard.com/blog/2009/08/25/the-sox-of-silence/

like image 26
DSBLR Avatar answered Sep 29 '22 13:09

DSBLR