mindspore.dataset.audio.MelScale
- 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
orNormType.NONE
. If norm isNormType.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
orMelType.HTK
. Default:MelType.HTK
.
- Raises
TypeError – If n_mels is not of type int.
ValueError – If n_mels is not positive.
TypeError – If sample_rate is not of type int.
ValueError – If sample_rate is not positive.
TypeError – If f_min is not of type float.
ValueError – If f_min is greater than or equal to f_max .
TypeError – If f_max is not of type float.
ValueError – If f_max is a negative number.
TypeError – If n_stft is not of type int.
ValueError – If n_stft is not positive.
TypeError – If norm is not of type
mindspore.dataset.audio.NormType
.TypeError – If mel_type is not of type
mindspore.dataset.audio.MelType
.
- 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: