mindspore.dataset.audio.Dither

class mindspore.dataset.audio.Dither(density_function=DensityFunction.TPDF, noise_shaping=False)[source]

Dither increases the perceived dynamic range of audio stored at a particular bit-depth by eliminating nonlinear truncation distortion.

Parameters
  • density_function (DensityFunction, optional) – The density function of a continuous random variable, can be DensityFunction.TPDF (Triangular Probability Density Function), DensityFunction.RPDF (Rectangular Probability Density Function) or DensityFunction.GPDF (Gaussian Probability Density Function). Default: DensityFunction.TPDF.

  • noise_shaping (bool, optional) – A filtering process that shapes the spectral energy of quantisation error. Default: False.

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.Dither()]
>>> 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.Dither()(waveform)
>>> print(output.shape, output.dtype)
(16,) float64
Tutorial Examples: