Class: TorchAudio::Transforms::AmplitudeToDB
- Inherits:
-
Torch::NN::Module
- Object
- Torch::NN::Module
- TorchAudio::Transforms::AmplitudeToDB
- Defined in:
- lib/torchaudio/transforms/amplitude_to_db.rb
Instance Method Summary collapse
- #forward(amplitude_spectrogram) ⇒ Object
-
#initialize(stype: :power, top_db: nil) ⇒ AmplitudeToDB
constructor
A new instance of AmplitudeToDB.
Constructor Details
#initialize(stype: :power, top_db: nil) ⇒ AmplitudeToDB
Returns a new instance of AmplitudeToDB.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/torchaudio/transforms/amplitude_to_db.rb', line 4 def initialize(stype: :power, top_db: nil) super() @stype = stype raise ArgumentError, 'top_db must be a positive numerical' if top_db && top_db.negative? @top_db = top_db @multiplier = stype == :power ? 10.0 : 20.0 @amin = 1e-10 @ref_value = 1.0 @db_multiplier = Math.log10([@amin, @ref_value].max) end |
Instance Method Details
#forward(amplitude_spectrogram) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/torchaudio/transforms/amplitude_to_db.rb', line 18 def forward(amplitude_spectrogram) F.amplitude_to_DB( amplitude_spectrogram, @multiplier, @amin, @db_multiplier, top_db: @top_db ) end |