mindspore.dataset.audio.Phaser
- class mindspore.dataset.audio.Phaser(sample_rate, gain_in=0.4, gain_out=0.74, delay_ms=3.0, decay=0.4, mod_speed=0.5, sinusoidal=True)[source]
Apply a phasing effect to the audio.
Similar to SoX implementation.
- Parameters
sample_rate (int) – Sampling rate of the waveform, e.g. 44100 (Hz).
gain_in (float, optional) – Desired input gain at the boost (or attenuation) in dB, in range of [0.0, 1.0]. Default:
0.4
.gain_out (float, optional) – Desired output gain at the boost (or attenuation) in dB, in range of [0.0, 1e9]. Default:
0.74
.delay_ms (float, optional) – Desired delay in milliseconds, in range of [0.0, 5.0]. Default:
3.0
.decay (float, optional) – Desired decay relative to gain-in, in range of [0.0, 0.99]. Default:
0.4
.mod_speed (float, optional) – Modulation speed in Hz, in range of [0.1, 2.0]. Default:
0.5
.sinusoidal (bool, optional) – If
True
, use sinusoidal modulation (preferable for multiple instruments). IfFalse
, use triangular modulation (gives single instruments a sharper phasing effect). Default:True
.
- Raises
TypeError – If sample_rate is not of type int.
TypeError – If gain_in is not of type float.
ValueError – If gain_in is not in range of [0.0, 1.0].
TypeError – If gain_out is not of type float.
ValueError – If gain_out is not in range of [0.0, 1e9].
TypeError – If delay_ms is not of type float.
ValueError – If delay_ms is not in range of [0.0, 5.0].
TypeError – If decay is not of type float.
ValueError – If decay is not in range of [0.0, 0.99].
TypeError – If mod_speed is not of type float.
ValueError – If mod_speed is not in range of [0.1, 2.0].
TypeError – If sinusoidal is not of type bool.
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 >>> >>> waveform = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float32) >>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"]) >>> transforms = [audio.Phaser(44100)] >>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
- Tutorial Examples: