mindspore.dataset.audio.MuLawEncoding

View Source On Gitee
class mindspore.dataset.audio.MuLawEncoding(quantization_channels=256)[source]

Encode signal based on mu-law companding.

Parameters

quantization_channels (int, optional) – Number of channels, which must be positive. Default: 256.

Raises
  • TypeError – If quantization_channels is not of type int.

  • ValueError – If quantization_channels is not a positive number.

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, 3, 4])  # 5 samples
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.MuLawEncoding()]
>>> 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
(3, 4) int32
>>>
>>> # Use the transform in eager mode
>>> waveform = np.random.random([3, 4])  # 1 sample
>>> output = audio.MuLawEncoding()(waveform)
>>> print(output.shape, output.dtype)
(3, 4) int32
Tutorial Examples: