0

I have two audios in different directories but having same name say a.wav But both the audios having different length, i want to make there length same and i'm not getting how do i do that.

Please find below the audio configurations.

Channels       : 1
Sample Rate    : 16000
Precision      : 16-bit
Duration       : 00:00:15.66 = 250586 samples ~ 1174.62 CDDA sectors
File Size      : 501k
Bit Rate       : 256k
Sample Encoding: 16-bit Signed Integer PCM

The other audio file configuration:

Input File     : 'a.wav'
Channels       : 1
Sample Rate    : 16000
Precision      : 16-bit
Duration       : 00:00:15.19 = 243040 samples ~ 1139.25 CDDA sectors
File Size      : 486k
Bit Rate       : 256k
Sample Encoding: 16-bit Signed Integer PCM
Rishabh Ojha
  • 57
  • 1
  • 8
  • using program [ffmpeg](http://ffmpeg.org/) you can convert video and audio - and it can also crop files. There are even modules for Python which use this program - `ffmpeg-python` and [moviepy](https://zulko.github.io/moviepy/) – furas Sep 11 '19 at 05:46

1 Answers1

2

If the audio files are close to the desired length, then

  1. Truncate/crop samples that are too long
  2. Pad samples that are too short. Zero-padding is common

If the audio files are very different size compared to the desired, you may want to divide very long files into shorter ones. Or to drop audio files that are way too short.

Note that if you want to apply machine learning, you may also want to split the audio into smaller fixed-size analysis windows. This answer implements that in combination with truncation.

Jon Nordby
  • 5,494
  • 1
  • 21
  • 50