mindspore.dataset.audio.DCShift

class mindspore.dataset.audio.DCShift(shift, limiter_gain=None)[source]

Apply a DC shift to the audio. This can be useful to remove DC offset from audio.

Parameters
  • shift (float) – The amount to shift the audio, the value must be in the range [-2.0, 2.0].

  • limiter_gain (float, optional) – Used only on peaks to prevent clipping, the value should be much less than 1, such as 0.05 or 0.02. Default: None, will be set to shift .

Raises
  • TypeError – If shift is not of type float.

  • ValueError – If shift is not in range [-2.0, 2.0].

  • TypeError – If limiter_gain is not of type float.

Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.audio as audio
>>>
>>> waveform = np.array([0.60, 0.97, -1.04, -1.26, 0.97, 0.91, 0.48, 0.93])
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.DCShift(0.5, 0.02)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
Tutorial Examples: