Unverified Commit fe30f30f authored by Jan Schlüter's avatar Jan Schlüter Committed by GitHub
Browse files

Allow zero momentum in Griffin-Lim (#601)

* Allow zero momentum in Griffin-Lim

* Skip momentum in Griffin-Lim if zero
parent b457cb71
...@@ -310,7 +310,7 @@ def griffinlim( ...@@ -310,7 +310,7 @@ def griffinlim(
torch.Tensor: waveform of (..., time), where time equals the ``length`` parameter if given. 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 < 1, 'momentum=%s > 1 can be unstable' % momentum
assert momentum > 0, 'momentum=%s < 0' % momentum assert momentum >= 0, 'momentum=%s < 0' % momentum
# pack batch # pack batch
shape = specgram.size() shape = specgram.size()
...@@ -348,7 +348,9 @@ def griffinlim( ...@@ -348,7 +348,9 @@ def griffinlim(
True, 'reflect', False, True) True, 'reflect', False, True)
# Update our phase estimates # 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)) angles = angles.div_(complex_norm(angles).add_(1e-16).unsqueeze(-1).expand_as(angles))
# Return the final phase estimates # Return the final phase estimates
......
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