Skip to content

Commit

Permalink
adopt changes from pytorch#1009
Browse files Browse the repository at this point in the history
  • Loading branch information
mthrok committed Nov 6, 2020
1 parent 0b89f9a commit 55e0c77
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions torchaudio/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ def spectrogram(
if normalized:
spec_f /= window.pow(2.).sum().sqrt()
if power is not None:
if power == 1.0:
return spec_f.abs()
if power == 2.0:
if spec_f.is_cuda:
return torch.view_as_real(spec_f).pow(power).sum(-1)
return spec_f.pow(power)
return spec_f.abs().pow(power)
return torch.view_as_real(spec_f)

Expand Down

0 comments on commit 55e0c77

Please sign in to comment.