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
>>>
>>> # Use the transform in dataset pipeline mode
>>> waveform = np.random.random([5, 10])  # 5 samples
>>> 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"])
>>> for item in numpy_slices_dataset.create_dict_iterator(num_epochs=1, output_numpy=True):
...     print(item["audio"].shape, item["audio"].dtype)
...     break
(10,) float64
>>>
>>> # Use the transform in eager mode
>>> waveform = np.random.random([10])  # 1 sample
>>> output = audio.LowpassBiquad(4000, 1500, 0.7)(waveform)
>>> print(output.shape, output.dtype)
(10,) float64
Tutorial Examples: