mindspore.dataset.audio.MuLawDecoding

class mindspore.dataset.audio.MuLawDecoding(quantization_channels=256)[源代码]

解码mu-law编码的信号,参考 mu-law算法

参数:
  • quantization_channels (int, 可选) - 通道数,必须为正数。默认值: 256

异常:
  • TypeError - 当 quantization_channels 的类型不为int。

  • ValueError - 当 quantization_channels 不为正数。

  • RuntimeError - 当输入音频的shape不为<…, time>。

支持平台:

CPU

样例:

>>> 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.MuLawDecoding()]
>>> 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) float64
>>>
>>> # Use the transform in eager mode
>>> waveform = np.random.random([3, 4])  # 1 sample
>>> output = audio.MuLawDecoding()(waveform)
>>> print(output.shape, output.dtype)
(3, 4) float64
教程样例: