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
hehl2
Torchaudio
Commits
e868060d
"tests/vscode:/vscode.git/clone" did not exist on "35db2fdea91dad8842d6d083d68e396c81b9e771"
Commit
e868060d
authored
Feb 11, 2019
by
David Pollack
Committed by
Soumith Chintala
Feb 12, 2019
Browse files
add friendly deprecation message (#81)
parent
7e15d2f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
test/test_transforms.py
test/test_transforms.py
+2
-1
torchaudio/transforms.py
torchaudio/transforms.py
+28
-1
No files found.
test/test_transforms.py
View file @
e868060d
...
...
@@ -150,7 +150,8 @@ class Tester(unittest.TestCase):
self
.
assertTrue
(
mel_transform
.
fm
.
fb
.
sum
(
1
).
le
(
1.
).
all
())
self
.
assertTrue
(
mel_transform
.
fm
.
fb
.
sum
(
1
).
ge
(
0.
).
all
())
# check options
mel_transform2
=
transforms
.
MelSpectrogram
(
window
=
torch
.
hamming_window
,
pad
=
10
,
ws
=
500
,
hop
=
125
,
n_fft
=
800
,
n_mels
=
50
)
kwargs
=
{
"window"
:
torch
.
hamming_window
,
"pad"
:
10
,
"ws"
:
500
,
"hop"
:
125
,
"n_fft"
:
800
,
"n_mels"
:
50
}
mel_transform2
=
transforms
.
MelSpectrogram
(
**
kwargs
)
spectrogram2_torch
=
mel_transform2
(
audio_scaled
)
# (1, 506, 50)
self
.
assertTrue
(
spectrogram2_torch
.
dim
()
==
3
)
self
.
assertTrue
(
spectrogram2_torch
.
le
(
0.
).
all
())
...
...
torchaudio/transforms.py
View file @
e868060d
from
__future__
import
division
,
print_function
from
warnings
import
warn
import
torch
import
numpy
as
np
class
Compose
(
object
):
"""Composes several transforms together.
...
...
@@ -150,6 +152,11 @@ class LC2CL(object):
return
self
.
__class__
.
__name__
+
'()'
def
SPECTROGRAM
(
*
args
,
**
kwargs
):
warn
(
"SPECTROGRAM has been renamed to Spectrogram"
)
return
Spectrogram
(
*
args
,
**
kwargs
)
class
Spectrogram
(
object
):
"""Create a spectrogram from a raw audio signal
...
...
@@ -200,6 +207,11 @@ class Spectrogram(object):
return
spec_f
def
F2M
(
*
args
,
**
kwargs
):
warn
(
"F2M has been renamed to MelScale"
)
return
MelScale
(
*
args
,
**
kwargs
)
class
MelScale
(
object
):
"""This turns a normal STFT into a mel frequency STFT, using a conversion
matrix. This uses triangular filter banks.
...
...
@@ -256,6 +268,11 @@ class MelScale(object):
return
700.
*
(
10
**
(
mel
/
2595.
)
-
1.
)
def
SPEC2DB
(
*
args
,
**
kwargs
):
warn
(
"SPEC2DB has been renamed to SpectogramToDB, please update your program"
)
return
SpectogramToDB
(
*
args
,
**
kwargs
)
class
SpectogramToDB
(
object
):
"""Turns a spectrogram from the power/amplitude scale to the decibel scale.
...
...
@@ -276,10 +293,15 @@ class SpectogramToDB(object):
spec_db
=
self
.
multiplier
*
torch
.
log10
(
spec
/
spec
.
max
())
# power -> dB
if
self
.
top_db
is
not
None
:
spec_db
=
torch
.
max
(
spec_db
,
spec_db
.
new_full
((
1
,),
self
.
top_db
))
spec_db
=
torch
.
max
(
spec_db
,
spec_db
.
new_full
((
1
,),
self
.
top_db
))
return
spec_db
def
MEL2
(
*
args
,
**
kwargs
):
warn
(
"MEL2 has been renamed to MelSpectrogram"
)
return
MelSpectrogram
(
*
args
,
**
kwargs
)
class
MelSpectrogram
(
object
):
"""Create MEL Spectrograms from a raw audio signal using the stft
function in PyTorch.
...
...
@@ -341,6 +363,11 @@ class MelSpectrogram(object):
return
spec_mel_db
def
MEL
(
*
args
,
**
kwargs
):
raise
DeprecationWarning
(
"MEL has been removed from the library please use MelSpectrogram or librosa"
)
class
BLC2CBL
(
object
):
"""Permute a 3d tensor from Bands x Sample length x Channels to Channels x
Bands x Samples length
...
...
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