mindspore.dataset.audio.transforms.BassBiquad
- class mindspore.dataset.audio.transforms.BassBiquad(sample_rate, gain, central_freq=100.0, Q=0.707)[source]
Design a bass tone-control effect, also known as two-pole low-shelf filter for audio waveform.
A low-shelf filter passes all frequencies, but increase or reduces frequencies below the shelf frequency by specified amount. The system function is:
\[H(s) = A\frac{s^2 + \frac{\sqrt{A}}{Q}s + A}{As^2 + \frac{\sqrt{A}}{Q}s + 1}\]Similar to SoX implementation.
Note
The dimension of the audio waveform to be processed needs to be (…, time).
- Parameters
sample_rate (int) – Sampling rate (in Hz), which can’t be zero.
gain (float) – Desired gain at the boost (or attenuation) in dB.
central_freq (float, optional) – Central frequency (in Hz). Default: 100.0.
Q (float, optional) – Quality factor , in range of (0, 1]. Default: 0.707.
- Raises
TypeError – If sample_rate is not of type integer.
ValueError – If sample_rate is 0.
TypeError – If gain is not of type float.
TypeError – If central_freq is not of type float.
TypeError – If Q is not of type float.
ValueError – If Q is not in range of (0, 1].
RuntimeError – If input tensor is not in shape of <…, time>.
- Supported Platforms:
CPU
Examples
>>> import numpy as np >>> >>> 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.BassBiquad(44100, 100.0)] >>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])