Skip to content

Conversation

@jaeyeun97
Copy link
Contributor

Implementation of Griffin-Lim Transformation for feature request #351
@vincentqb I am not quite sure how I might go about writing the test code for this.
Meanwhile, I have a simple comparison of the waveforms of the steam-train-whistle-daniel_simon.mp3 file, which by the looks and sounds seem to be working properly.

GriffinLim

@vincentqb
Copy link
Contributor

Thanks for submitting the PR!

  • We put the computation part of a transform in torchaudio/functional.py and then make the code in torchaudio/transforms.py just a wrapper around the functional.
  • torchaudio's code can be compared against librosa's output. And torchaudio's code is also tested for jitability. See examples in test/test_functional.py and test/test_transforms.py.
  • Python 2 support will be dropped after the upcoming release, so this pull request only needs to support Python 3.

Copy link
Contributor

@vincentqb vincentqb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make sure the code works as expected, the following test will need to be added.

  • compare against librosa's output (e.g. here), or a fixed example (say by exporting the output from librosa and loading in test).
  • jitability, e.g. here

See other examples in test/test_functional.py and test/test_transforms.py.

@jaeyeun97
Copy link
Contributor Author

jaeyeun97 commented Dec 14, 2019

@vincentqb Since torchaudio.functional.istft is not jitable, neither is this one--should I omit the latter test?

EDIT: made istft jitable instead :)

@jaeyeun97 jaeyeun97 changed the title Griffin-Lim Transformation Implementation [WIP] Griffin-Lim Transformation Implementation Dec 14, 2019
@jaeyeun97
Copy link
Contributor Author

jaeyeun97 commented Dec 14, 2019

@vincentqb As a part of implementing jitability for GriffinLim, I ended up writing jitability for istft as well. It passes the tests on my machine, but please double check?


if window is None:
window = torch.ones(win_length, requires_grad=False, device=device, dtype=dtype)
window = torch.ones(win_length)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to create the tensor and then move to a different device?

Copy link
Contributor Author

@jaeyeun97 jaeyeun97 Dec 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has to do with the JITability of the function: the signature of torch.ones seem not to allow for device and dtype setting when the out parameter is not specified. A workaround was to create the tensor then to move it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ones and eye tensor can be created on device directly. No need for two separate steps.

Copy link
Contributor Author

@jaeyeun97 jaeyeun97 Dec 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last time I checked, the function signatures required an out parameter when specifying the device. Since out needed to be of type Tensor and window is of Optional[Tensor], it complained. I might be misinterpreting the errors, though.

@vincentqb
Copy link
Contributor

vincentqb commented Dec 18, 2019

@vincentqb As a part of implementing jitability for GriffinLim, I ended up writing jitability for istft as well. It passes the tests on my machine, but please double check?

Thanks! jitability test looks good to me! and thanks for taking care of istft.

@jaeyeun97 jaeyeun97 requested a review from vincentqb December 24, 2019 10:37
Copy link
Contributor

@vincentqb vincentqb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Waiting on test to run, and will merge.

  • I removed the extra spectrogram step in test, and used smaller error bound.
  • I matched the signature of the transform to the docstring.

@vincentqb vincentqb changed the title [WIP] Griffin-Lim Transformation Implementation Griffin-Lim Transformation Implementation Dec 26, 2019
@vincentqb vincentqb merged commit 4a93469 into pytorch:master Dec 26, 2019
@jaeyeun97 jaeyeun97 deleted the feature_griffinlim branch December 27, 2019 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants