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
orModulation.TRIANGULAR
. Default:Modulation.SINUSOIDAL
.interpolation (Interpolation, optional) – Interpolation method, can be
Interpolation.LINEAR
orInterpolation.QUADRATIC
. Default:Interpolation.LINEAR
.
- Raises
TypeError – If sample_rate is not of type int.
ValueError – If sample_rate is zero.
TypeError – If delay is not of type float.
ValueError – If delay is not in range of [0, 30].
TypeError – If depth is not of type float.
ValueError – If depth is not in range of [0, 10].
TypeError – If regen is not of type float.
ValueError – If regen is not in range of [-95, 95].
TypeError – If width is not of type float.
ValueError – If width is not in range of [0, 100].
TypeError – If speed is not of type float.
ValueError – If speed is not in range of [0.1, 10].
TypeError – If phase is not of type float.
ValueError – If phase is not in range of [0, 100].
TypeError – If modulation is not of type
mindspore.dataset.audio.Modulation
.TypeError – If interpolation is not of type
mindspore.dataset.audio.Interpolation
.RuntimeError – If input tensor is not in shape of <…, channel, time>.
- Supported Platforms:
CPU
Examples
>>> import numpy as np >>> import mindspore.dataset as ds >>> import mindspore.dataset.audio as audio >>> >>> waveform = np.array([[2.716064453125e-03, 6.34765625e-03], [9.246826171875e-03, 1.0894775390625e-02]]) >>> 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"])
- Tutorial Examples: