mindspore.dataset.audio.Biquad

View Source On Gitee
class mindspore.dataset.audio.Biquad(b0, b1, b2, a0, a1, a2)[source]

Perform a biquad filter of input audio. Mathematical fomulas refer to: Digital_biquad_filter .

Parameters
  • b0 (float) – Numerator coefficient of current input, x[n].

  • b1 (float) – Numerator coefficient of input one time step ago x[n-1].

  • b2 (float) – Numerator coefficient of input two time steps ago x[n-2].

  • a0 (float) – Denominator coefficient of current output y[n], the value can’t be 0, typically 1.

  • a1 (float) – Denominator coefficient of current output y[n-1].

  • a2 (float) – Denominator coefficient of current output y[n-2].

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, 16])  # 5 samples
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.Biquad(0.01, 0.02, 0.13, 1, 0.12, 0.3)]
>>> 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.Biquad(0.01, 0.02, 0.13, 1, 0.12, 0.3)(waveform)
>>> print(output.shape, output.dtype)
(16,) float64
Tutorial Examples: