mindspore.dataset.audio.EqualizerBiquad
- class mindspore.dataset.audio.EqualizerBiquad(sample_rate, center_freq, gain, Q=0.707)[source]
Design biquad equalizer filter and perform filtering.
Similar to SoX implementation.
- Parameters
sample_rate (int) – Sampling rate of the waveform, e.g.
44100
(Hz), the value can’t be 0.center_freq (float) – Central frequency (in Hz).
gain (float) – Desired gain at the boost (or attenuation) in dB.
Q (float, optional) – https://en.wikipedia.org/wiki/Q_factor, range: (0, 1]. Default:
0.707
.
- Raises
TypeError – If sample_rate is not of type int.
ValueError – If sample_rate is 0.
TypeError – If center_freq is not of type float.
TypeError – If gain is not of type float.
TypeError – If Q is not of type float.
ValueError – If Q is not in range of (0, 1].
- 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, 16]) # 5 samples >>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"]) >>> transforms = [audio.EqualizerBiquad(44100, 1500, 5.5, 0.7)] >>> 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 (16,) float64 >>> >>> # Use the transform in eager mode >>> waveform = np.random.random([16]) # 1 sample >>> output = audio.EqualizerBiquad(44100, 1500, 5.5, 0.7)(waveform) >>> print(output.shape, output.dtype) (16,) float64
- Tutorial Examples: