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-5, tolerance_change=1e-8, 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.SLANEYor- NormType.NONE. Default:- NormType.NONE, no narmalization.
- mel_type (MelType, optional) – Mel scale to use, can be - MelType.SLANEYor- MelType.HTK. Default:- MelType.HTK.
 
- Raises
- TypeError – If n_stft is not of type int. 
- ValueError – If n_stft is not positive. 
- 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 max_iter is not of type int. 
- ValueError – If max_iter is a negative number. 
- TypeError – If tolerance_loss is not of type float. 
- ValueError – If tolerance_loss is a negative number. 
- TypeError – If tolerance_change is not of type float. 
- ValueError – If tolerance_change is a negative number. 
- TypeError – If sgdargs is not of type dict. 
- 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 >>> >>> # 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: