TIL: Trimming Silence From Audio Files With SoX
Audio recordings always have silence at the start and end. SoX removes it in one line.
sox input.wav output.wav silence -l 1 0.1 1% -l 1 0.1 1%
The silence effect detects and removes silent sections. The parameters set how much silence triggers a cut.
sox input.wav output.wav silence -l 1 0.3 5% -l 1 0.3 5%
Increase the thresholds to avoid cutting off quiet speech.
sox input.wav output.wav reverse silence -l 1 0.1 1% reverse
The reverse trick trims trailing silence. Reverse, trim what is now the start, reverse back.
Is SoX on macOS?
brew install sox
Batch processing?
Use find -exec or a for loop across a directory of files.