mindspore.dataset.audio.InverseMelScale

class mindspore.dataset.audio.InverseMelScale(n_stft, n_mels=128, sample_rate=16000, f_min=0.0, f_max=None, max_iter=100000, tolerance_loss=1e-05, tolerance_change=1e-08, sgdargs=None, norm=NormType.NONE, mel_type=MelType.HTK)[source]

Solve for a normal STFT from a mel frequency STFT, using a conversion matrix.

Parameters
  • n_stft (int) – Number of bins in STFT.

  • 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 .

  • max_iter (int, optional) – Maximum number of optimization iterations. Default: 100000.

  • tolerance_loss (float, optional) – Value of loss to stop optimization at. Default: 1e-5.

  • tolerance_change (float, optional) – Difference in losses to stop optimization at. Default: 1e-8.

  • sgdargs (dict, optional) – Arguments for the SGD optimizer. Default: None, will be set to {‘sgd_lr’: 0.1, ‘sgd_momentum’: 0.9}.

  • norm (NormType, optional) – Normalization method, can be NormType.SLANEY or NormType.NONE. Default: NormType.NONE, no narmalization.

  • mel_type (MelType, optional) – Mel scale to use, can 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
>>>
>>> # Use the transform in dataset pipeline mode
>>> waveform = np.random.randn(5, 8, 3, 2)  # 5 samples
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.InverseMelScale(20, 3, 16000, 0, 8000, 10)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
>>> for item in numpy_slices_dataset.create_dict_iterator(num_epochs=1, output_numpy=True):
...     print(item["audio"].shape, item["audio"].dtype)
...     break
(8, 20, 2) float64
>>>
>>> # Use the transform in eager mode
>>> waveform = np.random.random([8, 3, 2])  # 1 sample
>>> output = audio.InverseMelScale(20, 3, 16000, 0, 8000, 10)(waveform)
>>> print(output.shape, output.dtype)
(8, 20, 2) float64
Tutorial Examples: