mindspore.dataset.audio.MaskAlongAxis

class mindspore.dataset.audio.MaskAlongAxis(mask_start, mask_width, mask_value, axis)[source]

Apply a mask along axis . Mask will be applied from indices [mask_start, mask_start + mask_width) .

Parameters
  • mask_start (int) – Starting position of the mask, which must be non negative.

  • mask_width (int) – The width of the mask, which must be larger than 0.

  • mask_value (float) – Value to assign to the masked columns.

  • axis (int) – Axis to apply mask on (1 for frequency and 2 for time).

Raises
  • ValueError – If mask_start is invalid (< 0).

  • ValueError – If mask_width is invalid (< 1).

  • ValueError – If axis is not type of int or not within [1, 2].

Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.audio as audio
>>>
>>> waveform = np.random.random([1, 20, 20])
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.MaskAlongAxis(0, 10, 0.5, 1)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
Tutorial Examples: