mindspore.dataset.audio.DBToAmplitude

class mindspore.dataset.audio.DBToAmplitude(ref, power)[source]

Turn a waveform from the decibel scale to the power/amplitude scale.

Parameters
  • ref (float) – Reference which the output will be scaled by.

  • power (float) – If power equals 1, will compute DB to power. If 0.5, will compute DB to 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, 16])  # 5 samples
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.DBToAmplitude(0.5, 0.5)]
>>> 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
(16,) float64
>>>
>>> # Use the transform in eager mode
>>> waveform = np.random.random([16])  # 1 sample
>>> output = audio.DBToAmplitude(0.5, 0.5)(waveform)
>>> print(output.shape, output.dtype)
(16,) float64
Tutorial Examples: