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
fd9684c8
Commit
fd9684c8
authored
Aug 16, 2019
by
jamarshon
Committed by
cpuhrsch
Aug 16, 2019
Browse files
ISTFT window device for #240 (#242)
parent
35899095
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
torchaudio/functional.py
torchaudio/functional.py
+3
-2
No files found.
torchaudio/functional.py
View file @
fd9684c8
...
@@ -96,6 +96,7 @@ def istft(stft_matrix, # type: Tensor
...
@@ -96,6 +96,7 @@ def istft(stft_matrix, # type: Tensor
# add a channel dimension
# add a channel dimension
stft_matrix
=
stft_matrix
.
unsqueeze
(
0
)
stft_matrix
=
stft_matrix
.
unsqueeze
(
0
)
dtype
=
stft_matrix
.
dtype
device
=
stft_matrix
.
device
device
=
stft_matrix
.
device
fft_size
=
stft_matrix
.
size
(
1
)
fft_size
=
stft_matrix
.
size
(
1
)
assert
(
onesided
and
n_fft
//
2
+
1
==
fft_size
)
or
(
not
onesided
and
n_fft
==
fft_size
),
(
assert
(
onesided
and
n_fft
//
2
+
1
==
fft_size
)
or
(
not
onesided
and
n_fft
==
fft_size
),
(
...
@@ -114,7 +115,7 @@ def istft(stft_matrix, # type: Tensor
...
@@ -114,7 +115,7 @@ def istft(stft_matrix, # type: Tensor
assert
0
<
win_length
<=
n_fft
assert
0
<
win_length
<=
n_fft
if
window
is
None
:
if
window
is
None
:
window
=
torch
.
ones
(
win_length
)
window
=
torch
.
ones
(
win_length
,
requires_grad
=
False
,
device
=
device
,
dtype
=
dtype
)
assert
window
.
dim
()
==
1
and
window
.
size
(
0
)
==
win_length
assert
window
.
dim
()
==
1
and
window
.
size
(
0
)
==
win_length
...
@@ -137,7 +138,7 @@ def istft(stft_matrix, # type: Tensor
...
@@ -137,7 +138,7 @@ def istft(stft_matrix, # type: Tensor
ytmp
=
ytmp
.
transpose
(
1
,
2
)
# size (channel, n_fft, n_frames)
ytmp
=
ytmp
.
transpose
(
1
,
2
)
# size (channel, n_fft, n_frames)
eye
=
torch
.
eye
(
n_fft
,
requires_grad
=
False
,
eye
=
torch
.
eye
(
n_fft
,
requires_grad
=
False
,
device
=
device
).
unsqueeze
(
1
)
# size (n_fft, 1, n_fft)
device
=
device
,
dtype
=
dtype
).
unsqueeze
(
1
)
# size (n_fft, 1, n_fft)
# this does overlap add where the frames of ytmp are added such that the i'th frame of
# this does overlap add where the frames of ytmp are added such that the i'th frame of
# ytmp is added starting at i*hop_length in the output
# ytmp is added starting at i*hop_length in the output
...
...
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