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
b311c4cc
Commit
b311c4cc
authored
Feb 04, 2019
by
Jeremy Howard
Committed by
Soumith Chintala
Feb 04, 2019
Browse files
Bug fix: Use correct device for MEL2 functions so MEL2 works on CUDA tensors (#77)
parent
d62d3c0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
torchaudio/transforms.py
torchaudio/transforms.py
+3
-2
No files found.
torchaudio/transforms.py
View file @
b311c4cc
...
@@ -196,6 +196,7 @@ class SPECTROGRAM(object):
...
@@ -196,6 +196,7 @@ class SPECTROGRAM(object):
if
self
.
pad
>
0
:
if
self
.
pad
>
0
:
with
torch
.
no_grad
():
with
torch
.
no_grad
():
sig
=
torch
.
nn
.
functional
.
pad
(
sig
,
(
self
.
pad
,
self
.
pad
),
"constant"
)
sig
=
torch
.
nn
.
functional
.
pad
(
sig
,
(
self
.
pad
,
self
.
pad
),
"constant"
)
self
.
window
=
self
.
window
.
to
(
sig
.
device
)
spec_f
=
torch
.
stft
(
sig
,
self
.
n_fft
,
self
.
hop
,
self
.
ws
,
spec_f
=
torch
.
stft
(
sig
,
self
.
n_fft
,
self
.
hop
,
self
.
ws
,
self
.
window
,
center
=
False
,
self
.
window
,
center
=
False
,
normalized
=
True
,
onesided
=
True
).
transpose
(
1
,
2
)
normalized
=
True
,
onesided
=
True
).
transpose
(
1
,
2
)
...
@@ -225,7 +226,7 @@ class F2M(object):
...
@@ -225,7 +226,7 @@ class F2M(object):
def
__call__
(
self
,
spec_f
):
def
__call__
(
self
,
spec_f
):
if
self
.
fb
is
None
:
if
self
.
fb
is
None
:
self
.
fb
=
self
.
_create_fb_matrix
(
spec_f
.
size
(
2
))
self
.
fb
=
self
.
_create_fb_matrix
(
spec_f
.
size
(
2
))
.
to
(
spec_f
.
device
)
spec_m
=
torch
.
matmul
(
spec_f
,
self
.
fb
)
# (c, l, n_fft) dot (n_fft, n_mels) -> (c, l, n_mels)
spec_m
=
torch
.
matmul
(
spec_f
,
self
.
fb
)
# (c, l, n_fft) dot (n_fft, n_mels) -> (c, l, n_mels)
return
spec_m
return
spec_m
...
@@ -280,7 +281,7 @@ class SPEC2DB(object):
...
@@ -280,7 +281,7 @@ class SPEC2DB(object):
spec_db
=
self
.
multiplier
*
torch
.
log10
(
spec
/
spec
.
max
())
# power -> dB
spec_db
=
self
.
multiplier
*
torch
.
log10
(
spec
/
spec
.
max
())
# power -> dB
if
self
.
top_db
is
not
None
:
if
self
.
top_db
is
not
None
:
spec_db
=
torch
.
max
(
spec_db
,
torch
.
tensor
(
self
.
top_db
,
dtype
=
spec_db
.
dtype
))
spec_db
=
torch
.
max
(
spec_db
,
spec_db
.
new_full
((
1
,),
self
.
top_db
))
return
spec_db
return
spec_db
...
...
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