Source code for audaugio.augmentation.time_stretch

import librosa

from .augmentation_base import AugmentationBase


[docs]class TimeStretchAugmentation(AugmentationBase): """ Change the duration of a signal without changing its pitch. :param rate: factor by which to speed up or slow down the signal. When rate is 1, the signal is not modified. """ def __init__(self, rate): super().__init__(replaces=False) self.rate = rate
[docs] def augment(self, signal, sr): return [librosa.effects.time_stretch(signal, self.rate)]