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
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, 30])  # 5 sample
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.Vol(gain=10, gain_type=audio.GainType.DB)]
>>> 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
(30,) float64
>>>
>>> # Use the transform in eager mode
>>> waveform = np.random.random([30])  # 1 sample
>>> output = audio.Vol(gain=10, gain_type=audio.GainType.DB)(waveform)
>>> print(output.shape, output.dtype)
(30,) float64
Tutorial Examples: