How to extend sustain in batch wav files?

I have a batch of sound samples which are too short (2.15 sec), and I want to extend the sustain to a total of about 10 seconds, meaning stretch the last 0.50 second of the file to 10 seconds.
I can do this on each single file in audacity with paulstretch but was wondering if there’s a way to do so in batch from the command line.

Here is the original sample:


and here is the result I’d want:


Asked By: black-clover


It’s not possible to have sox stretch a sample by more than a factor of 10x directly. We could take an 0.5s sample and stretch it to 5s and then double that, but it gets complicated. Instead, I’ve chosen to take the last full second and stretch that.

play original.wav trim 0 -1.0 : tempo -m 0.1

You can batch process exactly as you’d expect, by using a loop:

for w in *.wav
    sox "$w" "stretch_$w" trim 0 -1.0 : tempo -m 0.1
Answered By: roaima
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.