mindspore.dataset.audio.Fade

class mindspore.dataset.audio.Fade(fade_in_len=0, fade_out_len=0, fade_shape=FadeShape.LINEAR)[源代码]

Add a fade in and/or fade out to an waveform.

Parameters
  • fade_in_len (int, optional) – Length of fade-in (time frames), which must be non-negative (default=0).

  • fade_out_len (int, optional) – Length of fade-out (time frames), which must be non-negative (default=0).

  • fade_shape (FadeShape, optional) –

    Shape of fade (default=FadeShape.LINEAR). Can be one of FadeShape.QUARTER_SINE, FadeShape.HALF_SINE, FadeShape.LINEAR, FadeShape.LOGARITHMIC or FadeShape.EXPONENTIAL.

    -FadeShape.QUARTER_SINE, means it tend to 0 in an quarter sin function.

    -FadeShape.HALF_SINE, means it tend to 0 in an half sin function.

    -FadeShape.LINEAR, means it linear to 0.

    -FadeShape.LOGARITHMIC, means it tend to 0 in an logrithmic function.

    -FadeShape.EXPONENTIAL, means it tend to 0 in an exponential function.

Raises

Examples

>>> import numpy as np
>>> from mindspore.dataset.audio import FadeShape
>>>
>>> waveform = np.array([[2.716064453125e-03, 6.34765625e-03, 9.246826171875e-03, 1.0894775390625e-02]])
>>> dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.Fade(fade_in_len=3, fade_out_len=2, fade_shape=FadeShape.LINEAR)]
>>> dataset = dataset.map(operations=transforms, input_columns=["audio"])