Skip to content
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

Allow zero momentum in Griffin-Lim #601

Merged
merged 2 commits into from
Apr 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions torchaudio/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def griffinlim(
torch.Tensor: waveform of (..., time), where time equals the ``length`` parameter if given.
"""
assert momentum < 1, 'momentum=%s > 1 can be unstable' % momentum
assert momentum > 0, 'momentum=%s < 0' % momentum
assert momentum >= 0, 'momentum=%s < 0' % momentum

# pack batch
shape = specgram.size()
Expand Down Expand Up @@ -348,7 +348,9 @@ def griffinlim(
True, 'reflect', False, True)

# Update our phase estimates
angles = rebuilt - tprev.mul_(momentum / (1 + momentum))
angles = rebuilt
if momentum:
angles = angles - tprev.mul_(momentum / (1 + momentum))
angles = angles.div_(complex_norm(angles).add_(1e-16).unsqueeze(-1).expand_as(angles))

# Return the final phase estimates
Expand Down