0

I have multiple wav files with the duration of 2.2 - 2.8 seconds. I want to modify (stretch/squeeze) them, such that all of them will be with the exact duration of 2.5 seconds. I mean slightly stretch the actual data and not just add leading/trailing zeros.

Is it possible?

Thanks

Cranjis
  • 1,590
  • 8
  • 31
  • 64
  • Is it possible? Yes. Do you care if the pitch changes? It is easier if the files are allowed to play faster or slower. If you want to keep the pitch the same, that gets into creating granules. I come more from the perspective of writing code (Java) to do this, than using a premade tool. If you have a programming language you are strong in, the algos for the former case can be more easily explained and coded. Granules are more difficult. – Phil Freihofner Jan 14 '20 at 05:27

2 Answers2

0

Yes, you can use https://github.com/waywardgeek/sonic like this:

 sonic -s 3.2 book.wav book_fast.wav
Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
0

I haven't found a simple solution with ffmpeg, but you can use RubberBand:

rubberband --duration d input.wav output.wav

(thanks to https://superuser.com/a/1132229/807246)


Example:

$ duration=2.5; for file in *.wav; do rubberband -D $duration $file out_${file}; done;
$ sox --info -D file.wav
2.390875
$ sox --info -D out_file.wav
2.500000
TGrif
  • 5,725
  • 9
  • 31
  • 52
  • how do I run rubberband from command line after I downloaded and install demo (for MAC)?https://rubberbandaudio.com/demo.html – Cranjis Jan 15 '20 at 06:22
  • I don't know, I'm on Linux. Try [this](https://breakfastquay.com/files/releases/rubberband-1.8.2-gpl-executable-macos.tar.bz2) maybe. – TGrif Jan 15 '20 at 16:33