Unverified Commit df776150 authored by nateanl's avatar nateanl Committed by GitHub
Browse files

Fix examples in transforms (#1646)

parent 658e3a88
...@@ -430,8 +430,9 @@ class MelSpectrogram(torch.nn.Module): ...@@ -430,8 +430,9 @@ class MelSpectrogram(torch.nn.Module):
mel_scale (str, optional): Scale to use: ``htk`` or ``slaney``. (Default: ``htk``) mel_scale (str, optional): Scale to use: ``htk`` or ``slaney``. (Default: ``htk``)
Example Example
>>> waveform, sample_rate = torchaudio.load('test.wav', normalization=True) >>> waveform, sample_rate = torchaudio.load('test.wav', normalize=True)
>>> mel_specgram = transforms.MelSpectrogram(sample_rate)(waveform) # (channel, n_mels, time) >>> transform = transforms.MelSpectrogram(sample_rate)
>>> mel_specgram = transform(waveform) # (channel, n_mels, time)
""" """
__constants__ = ['sample_rate', 'n_fft', 'win_length', 'hop_length', 'pad', 'n_mels', 'f_min'] __constants__ = ['sample_rate', 'n_fft', 'win_length', 'hop_length', 'pad', 'n_mels', 'f_min']
...@@ -1150,8 +1151,9 @@ class SpectralCentroid(torch.nn.Module): ...@@ -1150,8 +1151,9 @@ class SpectralCentroid(torch.nn.Module):
wkwargs (dict or None, optional): Arguments for window function. (Default: ``None``) wkwargs (dict or None, optional): Arguments for window function. (Default: ``None``)
Example Example
>>> waveform, sample_rate = torchaudio.load('test.wav', normalization=True) >>> waveform, sample_rate = torchaudio.load('test.wav', normalize=True)
>>> spectral_centroid = transforms.SpectralCentroid(sample_rate)(waveform) # (channel, time) >>> transform = transforms.SpectralCentroid(sample_rate)
>>> spectral_centroid = transform(waveform) # (channel, time)
""" """
__constants__ = ['sample_rate', 'n_fft', 'win_length', 'hop_length', 'pad'] __constants__ = ['sample_rate', 'n_fft', 'win_length', 'hop_length', 'pad']
...@@ -1201,8 +1203,9 @@ class PitchShift(torch.nn.Module): ...@@ -1201,8 +1203,9 @@ class PitchShift(torch.nn.Module):
If None, then ``torch.hann_window(win_length)`` is used (Default: ``None``). If None, then ``torch.hann_window(win_length)`` is used (Default: ``None``).
Example Example
>>> waveform, sample_rate = torchaudio.load('test.wav', normalization=True) >>> waveform, sample_rate = torchaudio.load('test.wav', normalize=True)
>>> waveform_shift = transforms.PitchShift(sample_rate, 4)(waveform) # (channel, time) >>> transform = transforms.PitchShift(sample_rate, 4)
>>> waveform_shift = transform(waveform) # (channel, time)
""" """
__constants__ = ['sample_rate', 'n_steps', 'bins_per_octave', 'n_fft', 'win_length', 'hop_length'] __constants__ = ['sample_rate', 'n_steps', 'bins_per_octave', 'n_fft', 'win_length', 'hop_length']
......
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