mindspore.dataset.audio.Filtfilt

View Source On Gitee
class mindspore.dataset.audio.Filtfilt(a_coeffs, b_coeffs, clamp=True)[source]

Apply an IIR filter forward and backward to a waveform.

Parameters
  • a_coeffs (Sequence[float]) – Denominator coefficients of difference equation of dimension. Lower delays coefficients are first, e.g. [a0, a1, a2, …]. Must be same size as b_coeffs (pad with 0’s as necessary).

  • b_coeffs (Sequence[float]) – Numerator coefficients of difference equation of dimension. Lower delays coefficients are first, e.g. [b0, b1, b2, …]. Must be same size as a_coeffs (pad with 0’s as necessary).

  • clamp (bool, optional) – If True, clamp the output signal to be in the range [-1, 1]. Default: True.

Raises
  • TypeError – If a_coeffs is not of type Sequence[float].

  • TypeError – If b_coeffs is not of type Sequence[float].

  • ValueError – If a_coeffs and b_coeffs are of different sizes.

  • TypeError – If clamp is not of type bool.

  • RuntimeError – If shape of the input audio is not <…, time>.

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.audio as audio
>>>
>>> waveform = np.array([[2.716064453125e-03, 6.34765625e-03], [9.246826171875e-03, 1.0894775390625e-02]])
>>> a_coeffs = [0.1, 0.2, 0.3]
>>> b_coeffs = [0.1, 0.2, 0.3]
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.Filtfilt(a_coeffs, b_coeffs)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
Tutorial Examples: