Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
1bd3dbb9
"vscode:/vscode.git/clone" did not exist on "f7ac7b604a6c8e96a8c2ee8b502fa725d3899df8"
Commit
1bd3dbb9
authored
Jul 27, 2018
by
Tongzhou Wang
Committed by
Soumith Chintala
Jul 27, 2018
Browse files
update torch audio for new stft signature (#55)
parent
18c01bef
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
torchaudio/transforms.py
torchaudio/transforms.py
+14
-3
No files found.
torchaudio/transforms.py
View file @
1bd3dbb9
...
...
@@ -192,7 +192,9 @@ class SPECTROGRAM(object):
self
.
sr
=
sr
self
.
ws
=
ws
self
.
hop
=
hop
if
hop
is
not
None
else
ws
//
2
self
.
n_fft
=
n_fft
# number of fft bins
# number of fft bins. the returned STFT result will have n_fft // 2 + 1
# number of frequecies due to onesided=True in torch.stft
self
.
n_fft
=
(
n_fft
-
1
)
*
2
if
n_fft
is
not
None
else
ws
self
.
pad
=
pad
self
.
wkwargs
=
wkwargs
...
...
@@ -212,8 +214,17 @@ class SPECTROGRAM(object):
assert
sig
.
dim
()
==
2
spec_f
=
torch
.
stft
(
sig
,
self
.
ws
,
self
.
hop
,
self
.
n_fft
,
True
,
True
,
self
.
window
,
self
.
pad
)
# (c, l, n_fft, 2)
if
self
.
pad
>
0
:
c
,
n
=
sig
.
size
()
new_sig
=
sig
.
new_empty
(
c
,
n
+
self
.
pad
*
2
)
new_sig
[:,
:
self
.
pad
].
zero_
()
new_sig
[:,
-
self
.
pad
:].
zero_
()
new_sig
.
narrow
(
1
,
self
.
pad
,
n
).
copy_
(
sig
)
sig
=
new_sig
spec_f
=
torch
.
stft
(
sig
,
self
.
n_fft
,
self
.
hop
,
self
.
ws
,
self
.
window
,
center
=
False
,
normalized
=
True
,
onesided
=
True
).
transpose
(
1
,
2
)
spec_f
/=
self
.
window
.
pow
(
2
).
sum
().
sqrt
()
spec_f
=
spec_f
.
pow
(
2
).
sum
(
-
1
)
# get power of "complex" tensor (c, l, n_fft)
return
spec_f
if
is_variable
else
spec_f
.
data
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment