AmplitudeToDB¶
- class torchaudio.transforms.AmplitudeToDB(stype: str = 'power', top_db: Optional[float] = None)[source]¶
Turn a tensor from the power/amplitude scale to the decibel scale.
This output depends on the maximum value in the input tensor, and so may return different values for an audio clip split into snippets vs. a a full clip.
- Parameters:
- Example
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True) >>> transform = transforms.AmplitudeToDB(stype="amplitude", top_db=80) >>> waveform_db = transform(waveform)
- Tutorials using
AmplitudeToDB
: - StreamWriter Basic Usage
- forward(x: Tensor) Tensor [source]¶
Numerically stable implementation from Librosa.
https://librosa.org/doc/latest/generated/librosa.amplitude_to_db.html
- Parameters:
x (Tensor) – Input tensor before being converted to decibel scale.
- Returns:
Output tensor in decibel scale.
- Return type:
Tensor