-
Notifications
You must be signed in to change notification settings - Fork 738
Example code for GriffinLim Audio transform #1671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@nateanl please help to review |
torchaudio/transforms.py
Outdated
| Example | ||
| >>> waveform, sample_rate = torchaudio.load('test.wav', normalize=True) | ||
| >>> transform = torchaudio.transforms.GriffinLim(n_fft=800) | ||
| >>> transgriffinlim = transform(waveform) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks incorrect. The input of transforms.GriffinLim should be a spectrogram. Could you change the waveform to a spectrogram?
torchaudio/transforms.py
Outdated
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation should be 4 spaces after Example. I just realized the space needs to be fixed in MuLawEncoding. But let me fix that.
torchaudio/transforms.py
Outdated
| Example | ||
| >>> waveform, sample_rate = torchaudio.load('test.wav', normalize=True) | ||
| >>> transform = torchaudio.transforms.GriffinLim(n_fft=800) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| >>> transform = torchaudio.transforms.GriffinLim(n_fft=800) | |
| >>> transform = transforms.GriffinLim(n_fft=800) |
torchaudio/transforms.py
Outdated
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not add transforms.Spectrogram in the example since it returns the complex-type tensor by default. GriffinLim requires the magnitude of the spectrogram which has real type.
Also the Example has indentation issue. Could you make changes in this way:
| 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) | |
| Example | |
| >>> batch, freq, time = 2, 257, 100 | |
| >>> spectrogram = torch.randn(batch, freq, time) | |
| >>> transform = transforms.GriffinLim(n_fft=512) | |
| >>> waveform = transform(spectrogram) |
torchaudio/transforms.py
Outdated
| Example | ||
| >>> batch, freq, time = 2, 257, 100 | ||
| >>> spectrogram = torch.randn(batch, freq, time) | ||
| >>> transform = transforms.GriffinLim(n_fft=512) | ||
| >>> waveform = transform(spectrogram) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentations still needs to be fixed. There should be only 4 spaces before Example and 8 spaces for the rest.
After fixing the indentation, the PR is good to be merged🙂 @harishsdev.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. LGTM!
No description provided.