mindspore.dataset.audio.Gain
- class mindspore.dataset.audio.Gain(gain_db=1.0)[源代码]
放大或衰减整个音频波形。
- 参数:
gain_db (float) - 增益调整,单位为分贝(dB)。默认值:
1.0
。
- 异常:
TypeError - 当 gain_db 的类型不为float。
- 支持平台:
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, 8]) # 5 samples >>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"]) >>> transforms = [audio.Gain(1.2)] >>> 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 (8,) float64 >>> >>> # Use the transform in eager mode >>> waveform = np.random.random([8]) # 1 sample >>> output = audio.Gain(1.2)(waveform) >>> print(output.shape, output.dtype) (8,) float64
- 教程样例: