mindspore.dataset.audio.Resample
- 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)[源代码]
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, which must be positive (default=16000).
new_freq (float, optional) – The desired frequency, which must be positive (default=16000).
resample_method (ResampleMethod, optional) – The resample method, which can be ResampleMethod.SINC_INTERPOLATION and ResampleMethod.KAISER_WINDOW (default=ResampleMethod.SINC_INTERPOLATION).
lowpass_filter_width (int, optional) – Controls the shaperness of the filter, more means sharper but less efficient, which 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, range: (0, 1] (default=0.99).
beta (float, optional) – The shape parameter used for kaiser window (default=None, will use 14.769656459379492).
Examples
>>> import numpy as np >>> 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"])