iver56 / audiomentations

A Python library for audio data augmentation. Inspired by albumentations. Useful for machine learning.
https://iver56.github.io/audiomentations/
MIT License
1.76k stars 183 forks source link

Implement AdjustDuration transform #241

Closed iver56 closed 1 year ago

iver56 commented 1 year ago

Should have a target duration parameter that can be specified either in seconds or in number of samples

If the input sound is longer than the target duration, pick a random offset (so we don't always output just the beginning of the audio) and crop the sound to the target duration

If the input sound is shorter than the target duration, pad the end of the sound (append digital silence) so the duration matches the target duration. Maybe it makes sense to support various padding modes here, just like in the Padding transform.

EvanWen036 commented 1 year ago

has this been implemented?

iver56 commented 1 year ago

No, not yet. If you are interested in helping, a pull request would be welcome 👍

iver56 commented 1 year ago