mindspore.dataset.audio.MelScale

View Source On Gitee
class mindspore.dataset.audio.MelScale(n_mels=128, sample_rate=16000, f_min=0.0, f_max=None, n_stft=201, norm=NormType.NONE, mel_type=MelType.HTK)[source]

Convert normal STFT to STFT at the Mel scale.

Parameters
  • n_mels (int, optional) – Number of mel filterbanks. Default: 128.

  • sample_rate (int, optional) – Sample rate of audio signal. Default: 16000.

  • f_min (float, optional) – Minimum frequency. Default: 0.0.

  • f_max (float, optional) – Maximum frequency. Default: None, will be set to sample_rate // 2 .

  • n_stft (int, optional) – Number of bins in STFT. Default: 201.

  • norm (NormType, optional) – Type of norm, value should be NormType.SLANEY or NormType.NONE. If norm is NormType.SLANEY, divide the triangular mel weight by the width of the mel band. Default: NormType.NONE, no narmalization.

  • mel_type (MelType, optional) – Type to use, value should be MelType.SLANEY or MelType.HTK. Default: MelType.HTK.

Raises
Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.audio as audio
>>>
>>> waveform = np.array([[0.8236, 0.2049, 0.3335], [0.5933, 0.9911, 0.2482],
...                      [0.3007, 0.9054, 0.7598], [0.5394, 0.2842, 0.5634], [0.6363, 0.2226, 0.2288]])
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.MelScale(4000, 1500, 0.7)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
Tutorial Examples: