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
fcc9a51a
Unverified
Commit
fcc9a51a
authored
Mar 24, 2020
by
tuxzz
Committed by
GitHub
Mar 24, 2020
Browse files
make istft fast again (#472)
parent
d7c79b39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
8 deletions
+6
-8
torchaudio/functional.py
torchaudio/functional.py
+6
-8
No files found.
torchaudio/functional.py
View file @
fcc9a51a
...
@@ -180,21 +180,19 @@ def istft(
...
@@ -180,21 +180,19 @@ def istft(
# each column of a channel is a frame which needs to be overlap added at the right place
# each column of a channel is a frame which needs to be overlap added at the right place
ytmp
=
ytmp
.
transpose
(
1
,
2
)
# size (channel, n_fft, n_frame)
ytmp
=
ytmp
.
transpose
(
1
,
2
)
# size (channel, n_fft, n_frame)
eye
=
torch
.
eye
(
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
y
=
torch
.
nn
.
functional
.
conv_transpose1
d
(
y
=
torch
.
nn
.
functional
.
fol
d
(
ytmp
,
eye
,
stride
=
hop_length
,
padding
=
0
ytmp
,
(
1
,
(
n_frame
-
1
)
*
hop_length
+
n_fft
),
(
1
,
n_fft
)
,
stride
=
(
1
,
hop_length
)
)
# size (channel, 1, expected_signal_len
)
)
.
squeeze
(
2
)
# do the same for the window function
# do the same for the window function
window_sq
=
(
window_sq
=
(
window
.
pow
(
2
).
view
(
n_fft
,
1
).
repeat
((
1
,
n_frame
)).
unsqueeze
(
0
)
window
.
pow
(
2
).
view
(
n_fft
,
1
).
repeat
((
1
,
n_frame
)).
unsqueeze
(
0
)
)
# size (1, n_fft, n_frame)
)
# size (1, n_fft, n_frame)
window_envelop
=
torch
.
nn
.
functional
.
conv_transpose1
d
(
window_envelop
=
torch
.
nn
.
functional
.
fol
d
(
window_sq
,
eye
,
stride
=
hop_length
,
padding
=
0
window_sq
,
(
1
,
(
n_frame
-
1
)
*
hop_length
+
n_fft
),
(
1
,
n_fft
)
,
stride
=
(
1
,
hop_length
)
)
# size (1, 1, expected_signal_len)
)
.
squeeze
(
2
)
# size (1, 1, expected_signal_len)
expected_signal_len
=
n_fft
+
hop_length
*
(
n_frame
-
1
)
expected_signal_len
=
n_fft
+
hop_length
*
(
n_frame
-
1
)
assert
y
.
size
(
2
)
==
expected_signal_len
assert
y
.
size
(
2
)
==
expected_signal_len
...
...
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