Shortcuts

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 feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript

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:
  • stype (str, optional) – scale of input tensor ("power" or "magnitude"). The power being the elementwise square of the magnitude. (Default: "power")

  • top_db (float or None, optional) – minimum negative cut-off in decibels. A reasonable number is 80. (Default: None)

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

StreamWriter Basic Usage

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

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources