mindspore.dataset.audio.Resample

View Source On Gitee
class mindspore.dataset.audio.Resample(orig_freq=16000, new_freq=16000, resample_method=ResampleMethod.SINC_INTERPOLATION, lowpass_filter_width=6, rolloff=0.99, beta=None)[source]

Resample a signal from one frequency to another. A resample method can be given.

Parameters
  • orig_freq (float, optional) – The original frequency of the signal, must be positive. Default: 16000.

  • new_freq (float, optional) – The desired frequency, must be positive. Default: 16000.

  • resample_method (ResampleMethod, optional) – The resample method to use, can be ResampleMethod.SINC_INTERPOLATION or ResampleMethod.KAISER_WINDOW. Default: ResampleMethod.SINC_INTERPOLATION.

  • lowpass_filter_width (int, optional) – Controls the sharpness of the filter, more means sharper but less efficient, must be positive. Default: 6.

  • rolloff (float, optional) – The roll-off frequency of the filter, as a fraction of the Nyquist. Lower values reduce anti-aliasing, but also reduce some of the highest frequencies, in range of (0, 1]. Default: 0.99.

  • beta (float, optional) – The shape parameter used for kaiser window. Default: None, will use 14.769656459379492.

Raises
Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.audio as audio
>>> from mindspore.dataset.audio import ResampleMethod
>>>
>>> waveform = np.random.random([1, 30])
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.Resample(orig_freq=48000, new_freq=16000,
...                              resample_method=ResampleMethod.SINC_INTERPOLATION,
...                              lowpass_filter_width=6, rolloff=0.99, beta=None)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
Tutorial Examples: