:py:mod:`tonic.audio_augmentations`
===================================

.. py:module:: tonic.audio_augmentations


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   tonic.audio_augmentations.RandomTimeStretch
   tonic.audio_augmentations.RandomPitchShift
   tonic.audio_augmentations.RandomAmplitudeScale
   tonic.audio_augmentations.AddWhiteNoise
   tonic.audio_augmentations.RIR




.. py:class:: RandomTimeStretch


   Time-stretch an audio sample by a fixed rate.
   :param samplerate: sample rate of the sample
   :type samplerate: float
   :param sample_length: sample length in seconds
   :type sample_length: int
   :param factors: range of desired factors for time stretch
   :type factors: float
   :param aug_index: index of the chosen factor for time stretch. It will be randomly chosen from the desired range (if not passed while initilization)
   :type aug_index: int
   :param caching: if we are caching the DiskCached dataset will dynamically pass copy index of data item to the transform (to set aug_index). Otherwise the aug_index will be chosen randomly in every call of transform
   :type caching: bool
   :param fix_length: if True, time stretched signal will be returned in a fixed length (samplerate * sample_length )
   :type fix_length: bool

   :param audio: data sample
   :type audio: np.ndarray

   :returns: time stretched data sample
   :rtype: np.ndarray

   .. py:attribute:: samplerate
      :type: float

      

   .. py:attribute:: sample_length
      :type: int

      

   .. py:attribute:: factors
      :type: list

      

   .. py:attribute:: aug_index
      :type: int
      :value: 0

      

   .. py:attribute:: caching
      :type: bool
      :value: False

      

   .. py:attribute:: fix_length
      :type: bool
      :value: True

      

   .. py:method:: __call__(audio: numpy.ndarray)



.. py:class:: RandomPitchShift


   Shift the pitch of a waveform by n_steps steps .

   :param samplerate: sample rate of the sample
   :type samplerate: float
   :param factors: range of desired factors for pitch shift
   :type factors: float
   :param aug_index: index of the chosen factor for pitchshift. It will be randomly chosen from the desired range (if not passed while initilization)
   :type aug_index: int
   :param caching: if we are caching, the DiskCached dataset will dynamically pass copy index of data item to the transform (to set aug_index). Otherwise the aug_index will be chosen randomly in every call of transform
   :type caching: bool

   :param audio: data sample
   :type audio: np.ndarray

   :returns: pitch shifted data sample
   :rtype: np.ndarray

   .. py:attribute:: samplerate
      :type: float

      

   .. py:attribute:: factors
      :type: list

      

   .. py:attribute:: aug_index
      :type: int
      :value: 0

      

   .. py:attribute:: caching
      :type: bool
      :value: False

      

   .. py:method:: __call__(audio: numpy.ndarray)



.. py:class:: RandomAmplitudeScale


   Scales the maximum amplitude of the incoming signal to a random amplitude chosen from a
   range.

   :param samplerate: sample rate of the sample
   :type samplerate: float
   :param min_amp: minimum of the amplitude range in volts
   :type min_amp: float
   :param max_amp: maximum of the amplitude range in volts
   :type max_amp: float
   :param factors: range of desired factors for amplitude scaling
   :type factors: float
   :param aug_index: index of the chosen factor for pitchshift. It will be randomly chosen from the desired range (if not passed while initilization)
   :type aug_index: int
   :param caching: if we are caching, the DiskCached dataset will dynamically pass copy index of data item to the transform (to set aug_index). Otherwise the aug_index will be chosen randomly in every call of transform
   :type caching: bool

   :param data: input (single-or multi-channel) signal.
   :type data: np.ndarray

   :returns: scaled version of the signal.
   :rtype: np.ndarray

   .. py:attribute:: samplerate
      :type: float

      

   .. py:attribute:: min_amp
      :type: float
      :value: 0.058

      

   .. py:attribute:: max_amp
      :type: float
      :value: 0.159

      

   .. py:attribute:: factors
      :type: list

      

   .. py:attribute:: aug_index
      :type: int
      :value: 0

      

   .. py:attribute:: caching
      :type: bool
      :value: False

      

   .. py:method:: __post_init__()


   .. py:method:: __call__(audio: numpy.ndarray)



.. py:class:: AddWhiteNoise


   Add white noise to the data sample with a known ratio.

   :param samplerate: sample rate of the sample
   :type samplerate: float
   :param factors: range of desired ratios for added noise
   :type factors: float
   :param aug_index: index of the chosen factor for noise. It will be randomly chosen from the desired range (if not passed while initilization)
   :type aug_index: int
   :param caching: if we are caching the DiskCached dataset will dynamically pass copy index of data item to the transform (to set aug_index). Otherwise the aug_index will be chosen randomly in every call of transform
   :type caching: bool

   :param audio: data sample
   :type audio: np.ndarray

   :returns: data sample with added noise
   :rtype: np.ndarray

   .. py:attribute:: samplerate
      :type: float

      

   .. py:attribute:: factors
      :type: list

      

   .. py:attribute:: aug_index
      :type: int
      :value: 0

      

   .. py:attribute:: caching
      :type: bool
      :value: False

      

   .. py:method:: __call__(audio: numpy.ndarray)



.. py:class:: RIR


   Convolves a RIR (room impluse response) to the data sample.

   :param samplerate: sample rate of the sample
   :type samplerate: float
   :param rir_audio: path to a sample room impluse response in the .wav format
   :type rir_audio: str
   :param caching: if we are caching the DiskCached dataset will dynamically pass copy index of data item to the transform (to set aug_index). Otherwise the aug_index will be chosen randomly in every call of transform
   :type caching: bool

   :param audio: data sample
   :type audio: np.ndarray

   :returns: data sample convolved with RIR
   :rtype: np.ndarray

   .. py:attribute:: samplerate
      :type: float

      

   .. py:attribute:: rir_audio
      :type: str

      

   .. py:attribute:: caching
      :type: bool
      :value: False

      

   .. py:method:: __call__(audio)



