From 3efcbd361ac9568192f23f9536b4e8d7813e563d Mon Sep 17 00:00:00 2001 From: harish Date: Fri, 11 Jun 2021 15:25:18 +0530 Subject: [PATCH 1/6] rebased --- torchaudio/transforms.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/torchaudio/transforms.py b/torchaudio/transforms.py index 5a9eda70d7..ba2b231933 100644 --- a/torchaudio/transforms.py +++ b/torchaudio/transforms.py @@ -67,6 +67,13 @@ class Spectrogram(torch.nn.Module): This argument is only effective when ``power=None``. It is ignored for cases where ``power`` is a number as in those cases, the returned tensor is power spectrogram, which is a real-valued tensor. + + Example + + >>> specgram = torch.randn(1, 40, 1000) + >>> specgram = torchaudio.transforms.Spectrogram()(specgram) + >>> specgram.shape + torch.Size([1, 40, 201, 6]) """ __constants__ = ['n_fft', 'win_length', 'hop_length', 'pad', 'power', 'normalized'] From 260ec963306acbe0f4639aef874d7f2a7208cdbf Mon Sep 17 00:00:00 2001 From: harish Date: Wed, 4 Aug 2021 12:36:35 +0530 Subject: [PATCH 2/6] GriffinLim transform example --- torchaudio/transforms.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/torchaudio/transforms.py b/torchaudio/transforms.py index ba2b231933..ce468c98af 100644 --- a/torchaudio/transforms.py +++ b/torchaudio/transforms.py @@ -154,6 +154,11 @@ class GriffinLim(torch.nn.Module): Values near 1 can lead to faster convergence, but above 1 may not converge. (Default: ``0.99``) length (int, optional): Array length of the expected output. (Default: ``None``) rand_init (bool, optional): Initializes phase randomly if True and to zero otherwise. (Default: ``True``) + + Example + >>> waveform, sample_rate = torchaudio.load('test.wav', normalize=True) + >>> transform = torchaudio.transforms.GriffinLim(n_fft=800) + >>> transgriffinlim = transform(waveform) """ __constants__ = ['n_fft', 'n_iter', 'win_length', 'hop_length', 'power', 'length', 'momentum', 'rand_init'] From 42e9dfeb9778cc19d1c684b5731d55434223f56b Mon Sep 17 00:00:00 2001 From: harish Date: Wed, 4 Aug 2021 13:42:34 +0530 Subject: [PATCH 3/6] added modified example code --- torchaudio/transforms.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/torchaudio/transforms.py b/torchaudio/transforms.py index ce468c98af..d8bfc7cb48 100644 --- a/torchaudio/transforms.py +++ b/torchaudio/transforms.py @@ -156,9 +156,11 @@ class GriffinLim(torch.nn.Module): rand_init (bool, optional): Initializes phase randomly if True and to zero otherwise. (Default: ``True``) Example - >>> waveform, sample_rate = torchaudio.load('test.wav', normalize=True) - >>> transform = torchaudio.transforms.GriffinLim(n_fft=800) - >>> transgriffinlim = transform(waveform) + >>> waveform, sample_rate = torchaudio.load('test.wav', normalize=True) + >>> transformgri = torchaudio.transforms.GriffinLim(n_fft=800) + >>> transformspec = torchaudio.transforms.Spectrogram(n_fft=800) + >>> x = transformspec(waveform) + >>> transgriffinlim = transformgri(x) """ __constants__ = ['n_fft', 'n_iter', 'win_length', 'hop_length', 'power', 'length', 'momentum', 'rand_init'] From 6194f20027f4eb5fb2abf1efa3a14dd698857ed6 Mon Sep 17 00:00:00 2001 From: harish Date: Wed, 4 Aug 2021 14:21:23 +0530 Subject: [PATCH 4/6] modified GriffinLim Example --- torchaudio/transforms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/torchaudio/transforms.py b/torchaudio/transforms.py index 513464e675..b6e4f8c195 100644 --- a/torchaudio/transforms.py +++ b/torchaudio/transforms.py @@ -158,8 +158,8 @@ class GriffinLim(torch.nn.Module): Example >>> waveform, sample_rate = torchaudio.load('test.wav', normalize=True) - >>> transformgri = torchaudio.transforms.GriffinLim(n_fft=800) - >>> transformspec = torchaudio.transforms.Spectrogram(n_fft=800) + >>> transformgri = transforms.GriffinLim(n_fft=800) + >>> transformspec = transforms.Spectrogram(n_fft=800) >>> x = transformspec(waveform) >>> transgriffinlim = transformgri(x) """ From edb83ed553b7ee0f3488d2fdfc87d69d75f91a54 Mon Sep 17 00:00:00 2001 From: harish Date: Wed, 4 Aug 2021 15:15:44 +0530 Subject: [PATCH 5/6] GriffinLim code modified --- torchaudio/transforms.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/torchaudio/transforms.py b/torchaudio/transforms.py index b6e4f8c195..0cc5e2bc07 100644 --- a/torchaudio/transforms.py +++ b/torchaudio/transforms.py @@ -157,11 +157,10 @@ class GriffinLim(torch.nn.Module): rand_init (bool, optional): Initializes phase randomly if True and to zero otherwise. (Default: ``True``) Example - >>> waveform, sample_rate = torchaudio.load('test.wav', normalize=True) - >>> transformgri = transforms.GriffinLim(n_fft=800) - >>> transformspec = transforms.Spectrogram(n_fft=800) - >>> x = transformspec(waveform) - >>> transgriffinlim = transformgri(x) + >>> batch, freq, time = 2, 257, 100 + >>> spectrogram = torch.randn(batch, freq, time) + >>> transform = transforms.GriffinLim(n_fft=512) + >>> waveform = transform(spectrogram) """ __constants__ = ['n_fft', 'n_iter', 'win_length', 'hop_length', 'power', 'length', 'momentum', 'rand_init'] From bc4742dc3b96a2c5c3ece72356fdc237a4c00c68 Mon Sep 17 00:00:00 2001 From: harish Date: Wed, 4 Aug 2021 16:02:39 +0530 Subject: [PATCH 6/6] modified for tab issues --- torchaudio/transforms.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/torchaudio/transforms.py b/torchaudio/transforms.py index 0cc5e2bc07..3c2a072127 100644 --- a/torchaudio/transforms.py +++ b/torchaudio/transforms.py @@ -156,11 +156,11 @@ class GriffinLim(torch.nn.Module): length (int, optional): Array length of the expected output. (Default: ``None``) rand_init (bool, optional): Initializes phase randomly if True and to zero otherwise. (Default: ``True``) - Example - >>> batch, freq, time = 2, 257, 100 - >>> spectrogram = torch.randn(batch, freq, time) - >>> transform = transforms.GriffinLim(n_fft=512) - >>> waveform = transform(spectrogram) + Example + >>> batch, freq, time = 2, 257, 100 + >>> spectrogram = torch.randn(batch, freq, time) + >>> transform = transforms.GriffinLim(n_fft=512) + >>> waveform = transform(spectrogram) """ __constants__ = ['n_fft', 'n_iter', 'win_length', 'hop_length', 'power', 'length', 'momentum', 'rand_init']