mindspore.dataset.audio.MFCC

View Source On Gitee
class mindspore.dataset.audio.MFCC(sample_rate=16000, n_mfcc=40, dct_type=2, norm=NormMode.ORTHO, log_mels=False, melkwargs=None)[source]

Create MFCC for a raw audio signal.

Parameters
  • sample_rate (int, optional) – Sampling rate of audio signal (in Hz), can’t be less than 0. Default: 16000.

  • n_mfcc (int, optional) – Number of mfc coefficients to retain, can’t be less than 0. Default: 40.

  • dct_type (int, optional) – Type of DCT (discrete cosine transform) to use, can only be 2. Default: 2.

  • norm (NormMode, optional) – Norm to use. Default: NormMode.ORTHO.

  • log_mels (bool, optional) – Whether to use log-mel spectrograms instead of db-scaled. Default: False.

  • melkwargs (dict, optional) –

    Arguments for mindspore.dataset.audio.MelSpectrogram. Default: None, the default setting is a dict including

    • ’n_fft’: 400

    • ’win_length’: n_fft

    • ’hop_length’: win_length // 2

    • ’f_min’: 0.0

    • ’f_max’: sample_rate // 2

    • ’pad’: 0

    • ’window’: WindowType.HANN

    • ’power’: 2.0

    • ’normalized’: False

    • ’center’: True

    • ’pad_mode’: BorderType.REFLECT

    • ’onesided’: True

    • ’norm’: NormType.NONE

    • ’mel_scale’: 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.MFCC(4000, 1500, 2)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
Tutorial Examples: