kjakeb
kjakeb

Reputation: 7600

Remove sections of audio in SoX

What's the easiest way to remove the specified sections of a wav file using SoX? Right now I use the trim command to break up the file and then concatenate the parts. However, that seems a little tedious and backwards since trim takes a section of audio and copies it to a new file, so I have to trim the opposite of the the sections that I specify to remove, and then concatenate those. Any help appreciated, thanks!

Upvotes: 2

Views: 1759

Answers (1)

JJoao
JJoao

Reputation: 5347

This is ugly but... try:

sox  "|sox  in.wav -p trim 0 start" "|sox in.wav -p trim length" out.wav

Where start is the the offset of the removing area and length is the number of seconds to remove

Example: to remove between 30s and 50s:

sox  "|sox  in.wav -p trim 0 30" "|sox in.wav -p trim 20" out.wav

Update -- a better solution:

sox in.wav out.wav   trim 0 =start =end

Example: to remove between 30s and 50s:

sox in.wav out.wav   trim 0 =30 =50

Upvotes: 1

Related Questions