mindspore.dataset.audio.Flanger

class mindspore.dataset.audio.Flanger(sample_rate, delay=0.0, depth=2.0, regen=0.0, width=71.0, speed=0.5, phase=25.0, modulation=Modulation.SINUSOIDAL, interpolation=Interpolation.LINEAR)[source]

Apply a flanger effect to the audio.

Similar to SoX implementation.

Parameters
  • sample_rate (int) – Sampling rate of the waveform, e.g. 44100 (Hz).

  • delay (float, optional) – Desired delay in milliseconds, in range of [0, 30]. Default: 0.0.

  • depth (float, optional) – Desired delay depth in milliseconds, in range of [0, 10]. Default: 2.0.

  • regen (float, optional) – Desired regen (feedback gain) in dB, in range of [-95, 95]. Default: 0.0.

  • width (float, optional) – Desired width (delay gain) in dB, in range of [0, 100]. Default: 71.0.

  • speed (float, optional) – Modulation speed in Hz, in range of [0.1, 10]. Default: 0.5.

  • phase (float, optional) – Percentage phase-shift for multi-channel, in range of [0, 100]. Default: 25.0.

  • modulation (Modulation, optional) – Modulation method, can be Modulation.SINUSOIDAL or Modulation.TRIANGULAR. Default: Modulation.SINUSOIDAL.

  • interpolation (Interpolation, optional) – Interpolation method, can be Interpolation.LINEAR or Interpolation.QUADRATIC. Default: Interpolation.LINEAR.

Raises
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, 4, 16])  # 5 samples
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.Flanger(44100)]
>>> 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
(4, 16) float64
>>>
>>> # Use the transform in eager mode
>>> waveform = np.random.random([4, 16])  # 1 sample
>>> output = audio.Flanger(44100)(waveform)
>>> print(output.shape, output.dtype)
(4, 16) float64
Tutorial Examples: