mindspore.dataset.audio.Overdrive

class mindspore.dataset.audio.Overdrive(gain=20.0, color=20.0)[source]

Apply an overdrive effect to the audio waveform.

Similar to SoX implementation.

Parameters
  • gain (float, optional) – Desired gain at the boost (or attenuation) in dB, in range of [0, 100]. Default: 20.0.

  • color (float, optional) – Controls the amount of even harmonic content in the over-driven output, in range of [0, 100]. Default: 20.0.

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

  • ValueError – If gain is not in range of [0, 100].

  • TypeError – If color is not of type float.

  • ValueError – If color is not in range of [0, 100].

  • RuntimeError – If input tensor is not in shape of <…, time>.

Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.audio as audio
>>>
>>> # Use the transform in dataset pipeline mode
>>> waveform = np.random.random([5, 10])  # 5 samples
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.Overdrive()]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
>>> for item in numpy_slices_dataset.create_dict_iterator(num_epochs=1, output_numpy=True):
...     print(item["audio"].shape, item["audio"].dtype)
...     break
(10,) float64
>>>
>>> # Use the transform in eager mode
>>> waveform = np.random.random([10])  # 1 sample
>>> output = audio.Overdrive()(waveform)
>>> print(output.shape, output.dtype)
(10,) float64
Tutorial Examples: