Shortcuts

torchaudio.functional.amplitude_to_DB

torchaudio.functional.amplitude_to_DB(x: Tensor, multiplier: float, amin: float, db_multiplier: float, top_db: Optional[float] = None) Tensor[source]

Turn a spectrogram 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

The output of each tensor in a batch depends on the maximum value of that tensor, and so may return different values for an audio clip split into snippets vs. a full clip.

Parameters:
  • x (Tensor) –

    Input spectrogram(s) before being converted to decibel scale. The expected shapes are (freq, time), (channel, freq, time) or (..., batch, channel, freq, time).

    Note

    When top_db is specified, cut-off values are computed for each audio in the batch. Therefore if the input shape is 4D (or larger), different cut-off values are used for audio data in the batch. If the input shape is 2D or 3D, a single cutoff value is used.

  • multiplier (float) – Use 10. for power and 20. for amplitude

  • amin (float) – Number to clamp x

  • db_multiplier (float) – Log10(max(reference value and amin))

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

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