Commit ccb2d6f2 authored by Ravi Makhija's avatar Ravi Makhija Committed by Facebook GitHub Bot
Browse files

Added example for Vol transform (#2597)

Summary:
Added example for [Vol transform](https://pytorch.org/audio/stable/transforms.html#torchaudio.transforms.Vol) as mentioned in this issue https://github.com/pytorch/audio/issues/1564.

Also made a minor edit to the docstring for `class Vol` to fix a grammar typo and use more common verbiage.

Pull Request resolved: https://github.com/pytorch/audio/pull/2597

Reviewed By: nateanl, mthrok

Differential Revision: D38316433

Pulled By: carolineechen

fbshipit-source-id: 0be8fc505800a59acdab843813767acfdeac8243
parent e646de72
...@@ -1252,7 +1252,7 @@ class TimeMasking(_AxisMasking): ...@@ -1252,7 +1252,7 @@ class TimeMasking(_AxisMasking):
class Vol(torch.nn.Module): class Vol(torch.nn.Module):
r"""Add a volume to an waveform. r"""Adjust volume of waveform.
.. devices:: CPU CUDA .. devices:: CPU CUDA
...@@ -1264,6 +1264,11 @@ class Vol(torch.nn.Module): ...@@ -1264,6 +1264,11 @@ class Vol(torch.nn.Module):
If ``gain_type`` = ``power``, ``gain`` is a power (voltage squared). If ``gain_type`` = ``power``, ``gain`` is a power (voltage squared).
If ``gain_type`` = ``db``, ``gain`` is in decibels. If ``gain_type`` = ``db``, ``gain`` is in decibels.
gain_type (str, optional): Type of gain. One of: ``amplitude``, ``power``, ``db`` (Default: ``amplitude``) gain_type (str, optional): Type of gain. One of: ``amplitude``, ``power``, ``db`` (Default: ``amplitude``)
Example
>>> waveform, sample_rate = torchaudio.load('test.wav', normalize=True)
>>> transform = transforms.Vol(gain=0.5, gain_type="amplitude")
>>> quieter_waveform = transform(waveform)
""" """
def __init__(self, gain: float, gain_type: str = "amplitude"): def __init__(self, gain: float, gain_type: str = "amplitude"):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment