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
36a1e90e
Unverified
Commit
36a1e90e
authored
May 13, 2020
by
tbright17
Committed by
GitHub
May 13, 2020
Browse files
Make power and normalized configurable for torchaudio.transforms.MelSpectrogram (#633)
parent
b7f192fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
torchaudio/transforms.py
torchaudio/transforms.py
+6
-2
No files found.
torchaudio/transforms.py
View file @
36a1e90e
...
...
@@ -395,6 +395,8 @@ class MelSpectrogram(torch.nn.Module):
pad
:
int
=
0
,
n_mels
:
int
=
128
,
window_fn
:
Callable
[...,
Tensor
]
=
torch
.
hann_window
,
power
:
Optional
[
float
]
=
2.
,
normalized
:
bool
=
False
,
wkwargs
:
Optional
[
dict
]
=
None
)
->
None
:
super
(
MelSpectrogram
,
self
).
__init__
()
self
.
sample_rate
=
sample_rate
...
...
@@ -402,13 +404,15 @@ class MelSpectrogram(torch.nn.Module):
self
.
win_length
=
win_length
if
win_length
is
not
None
else
n_fft
self
.
hop_length
=
hop_length
if
hop_length
is
not
None
else
self
.
win_length
//
2
self
.
pad
=
pad
self
.
power
=
power
self
.
normalized
=
normalized
self
.
n_mels
=
n_mels
# number of mel frequency bins
self
.
f_max
=
f_max
self
.
f_min
=
f_min
self
.
spectrogram
=
Spectrogram
(
n_fft
=
self
.
n_fft
,
win_length
=
self
.
win_length
,
hop_length
=
self
.
hop_length
,
pad
=
self
.
pad
,
window_fn
=
window_fn
,
power
=
2.
,
normalized
=
False
,
wkwargs
=
wkwargs
)
pad
=
self
.
pad
,
window_fn
=
window_fn
,
power
=
self
.
power
,
normalized
=
self
.
normalized
,
wkwargs
=
wkwargs
)
self
.
mel_scale
=
MelScale
(
self
.
n_mels
,
self
.
sample_rate
,
self
.
f_min
,
self
.
f_max
,
self
.
n_fft
//
2
+
1
)
def
forward
(
self
,
waveform
:
Tensor
)
->
Tensor
:
...
...
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