Class: TorchAudio::Transforms::Fade

Inherits:
Torch::NN::Module
  • Object
show all
Defined in:
lib/torchaudio/transforms/fade.rb

Instance Method Summary collapse

Constructor Details

#initialize(fade_in_len: 0, fade_out_len: 0, fade_shape: "linear") ⇒ Fade

Returns a new instance of Fade.



4
5
6
7
8
9
# File 'lib/torchaudio/transforms/fade.rb', line 4

def initialize(fade_in_len: 0, fade_out_len: 0, fade_shape: "linear")
  super()
  @fade_in_len = fade_in_len
  @fade_out_len = fade_out_len
  @fade_shape = fade_shape
end

Instance Method Details

#forward(waveform) ⇒ Object



11
12
13
14
15
# File 'lib/torchaudio/transforms/fade.rb', line 11

def forward(waveform)
  waveform_length = waveform.size[-1]
  device = waveform.device
  fade_in(waveform_length).to(device) * fade_out(waveform_length).to(device) * waveform
end