mindspore.dataset.audio.PhaseVocoder
- class mindspore.dataset.audio.PhaseVocoder(rate, phase_advance)[source]
Given a STFT spectrogram, speed up in time without modifying pitch by a factor of rate.
- Parameters
rate (float) – Speed-up factor.
phase_advance (numpy.ndarray) – Expected phase advance in each bin, in shape of (freq, 1).
- Raises
TypeError – If rate is not of type float.
ValueError – If rate is not a positive number.
TypeError – If phase_advance is not of type
numpy.ndarray
.RuntimeError – If input tensor is not in shape of <…, freq, num_frame, complex=2>.
- 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.random([5, 44, 10, 2]) # 5 samples >>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"]) >>> transforms = [audio.PhaseVocoder(rate=2, phase_advance=np.random.random([44, 1]))] >>> 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 (44, 5, 2) float64 >>> >>> # Use the transform in eager mode >>> waveform = np.random.random([44, 10, 2]) # 1 sample >>> output = audio.PhaseVocoder(rate=2, phase_advance=np.random.random([44, 1]))(waveform) >>> print(output.shape, output.dtype) (44, 5, 2) float64
- Tutorial Examples: