mindspore.dataset.audio.LowpassBiquad

class mindspore.dataset.audio.LowpassBiquad(sample_rate, cutoff_freq, Q=0.707)[source]

Design two-pole low-pass filter for audio waveform.

A low-pass filter passes frequencies lower than a selected cutoff frequency but attenuates frequencies higher than it. The system function is:

\[H(s) = \frac{1}{s^2 + \frac{s}{Q} + 1}\]

Similar to SoX implementation.

Note

The shape of the audio waveform to be processed needs to be <…, time>.

Parameters
  • sample_rate (int) – Sampling rate (in Hz), which can’t be zero.

  • cutoff_freq (float) – Filter cutoff frequency (in Hz).

  • Q (float, optional) – Quality factor , in range of (0, 1]. Default: 0.707.

Raises
Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.audio as audio
>>>
>>> waveform = np.array([[0.8236, 0.2049, 0.3335], [0.5933, 0.9911, 0.2482],
...                      [0.3007, 0.9054, 0.7598], [0.5394, 0.2842, 0.5634], [0.6363, 0.2226, 0.2288]])
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.LowpassBiquad(4000, 1500, 0.7)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
Tutorial Examples: