mindspore.dataset.audio.Vol
- class mindspore.dataset.audio.Vol(gain, gain_type=GainType.AMPLITUDE)[source]
Adjust volume of waveform.
- Parameters
gain (float) – Gain at the boost (or attenuation). If gain_type is GainType.AMPLITUDE, it is a non negative amplitude ratio. If gain_type is GainType.POWER, it is a power (voltage squared). If gain_type is GainType.DB, it is in decibels.
gain_type (GainType, optional) – Type of gain, can be GainType.AMPLITUDE, GainType.POWER or GainType.DB. Default: GainType.AMPLITUDE.
- Raises
TypeError – If gain is not of type float.
TypeError – If gain_type is not of type
mindspore.dataset.audio.GainType
.ValueError – If gain is a negative number when gain_type is GainType.AMPLITUDE.
ValueError – If gain is not a positive number when gain_type is GainType.POWER.
RuntimeError – If input tensor is not in shape of <…, time>.
- Supported Platforms:
CPU
Examples
>>> import numpy as np >>> from mindspore.dataset.audio import GainType >>> >>> waveform = np.random.random([20, 30]) >>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"]) >>> transforms = [audio.Vol(gain=10, gain_type=GainType.DB)] >>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])