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
6a43e9eb
Commit
6a43e9eb
authored
Jul 24, 2019
by
jamarshon
Committed by
cpuhrsch
Jul 24, 2019
Browse files
Renaming MuLawExpanding to MuLawDecoding (#159)
parent
b29a4639
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
11 deletions
+11
-11
test/test_jit.py
test/test_jit.py
+5
-5
test/test_transforms.py
test/test_transforms.py
+1
-1
torchaudio/functional.py
torchaudio/functional.py
+2
-2
torchaudio/transforms.py
torchaudio/transforms.py
+3
-3
No files found.
test/test_jit.py
View file @
6a43e9eb
...
@@ -170,25 +170,25 @@ class Test_JIT(unittest.TestCase):
...
@@ -170,25 +170,25 @@ class Test_JIT(unittest.TestCase):
self
.
_test_script_module
(
tensor
,
transforms
.
MuLawEncoding
)
self
.
_test_script_module
(
tensor
,
transforms
.
MuLawEncoding
)
def
test_torchscript_mu_law_
expan
ding
(
self
):
def
test_torchscript_mu_law_
deco
ding
(
self
):
@
torch
.
jit
.
script
@
torch
.
jit
.
script
def
jit_method
(
tensor
,
qc
):
def
jit_method
(
tensor
,
qc
):
# type: (Tensor, int) -> Tensor
# type: (Tensor, int) -> Tensor
return
F
.
mu_law_
expan
ding
(
tensor
,
qc
)
return
F
.
mu_law_
deco
ding
(
tensor
,
qc
)
tensor
=
torch
.
rand
((
1
,
10
))
tensor
=
torch
.
rand
((
1
,
10
))
qc
=
256
qc
=
256
jit_out
=
jit_method
(
tensor
,
qc
)
jit_out
=
jit_method
(
tensor
,
qc
)
py_out
=
F
.
mu_law_
expan
ding
(
tensor
,
qc
)
py_out
=
F
.
mu_law_
deco
ding
(
tensor
,
qc
)
self
.
assertTrue
(
torch
.
allclose
(
jit_out
,
py_out
))
self
.
assertTrue
(
torch
.
allclose
(
jit_out
,
py_out
))
@
unittest
.
skipIf
(
not
RUN_CUDA
,
"no CUDA"
)
@
unittest
.
skipIf
(
not
RUN_CUDA
,
"no CUDA"
)
def
test_scriptmodule_MuLaw
Expan
ding
(
self
):
def
test_scriptmodule_MuLaw
Deco
ding
(
self
):
tensor
=
torch
.
rand
((
1
,
10
),
device
=
"cuda"
)
tensor
=
torch
.
rand
((
1
,
10
),
device
=
"cuda"
)
self
.
_test_script_module
(
tensor
,
transforms
.
MuLaw
Expan
ding
)
self
.
_test_script_module
(
tensor
,
transforms
.
MuLaw
Deco
ding
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
test/test_transforms.py
View file @
6a43e9eb
...
@@ -61,7 +61,7 @@ class Tester(unittest.TestCase):
...
@@ -61,7 +61,7 @@ class Tester(unittest.TestCase):
waveform_mu
=
transforms
.
MuLawEncoding
(
quantization_channels
)(
waveform
)
waveform_mu
=
transforms
.
MuLawEncoding
(
quantization_channels
)(
waveform
)
self
.
assertTrue
(
waveform_mu
.
min
()
>=
0.
and
waveform_mu
.
max
()
<=
quantization_channels
)
self
.
assertTrue
(
waveform_mu
.
min
()
>=
0.
and
waveform_mu
.
max
()
<=
quantization_channels
)
waveform_exp
=
transforms
.
MuLaw
Expan
ding
(
quantization_channels
)(
waveform_mu
)
waveform_exp
=
transforms
.
MuLaw
Deco
ding
(
quantization_channels
)(
waveform_mu
)
self
.
assertTrue
(
waveform_exp
.
min
()
>=
-
1.
and
waveform_exp
.
max
()
<=
1.
)
self
.
assertTrue
(
waveform_exp
.
min
()
>=
-
1.
and
waveform_exp
.
max
()
<=
1.
)
def
test_mel2
(
self
):
def
test_mel2
(
self
):
...
...
torchaudio/functional.py
View file @
6a43e9eb
...
@@ -10,7 +10,7 @@ __all__ = [
...
@@ -10,7 +10,7 @@ __all__ = [
'spectrogram_to_DB'
,
'spectrogram_to_DB'
,
'create_dct'
,
'create_dct'
,
'mu_law_encoding'
,
'mu_law_encoding'
,
'mu_law_
expan
ding'
,
'mu_law_
deco
ding'
,
'complex_norm'
,
'complex_norm'
,
'angle'
,
'angle'
,
'magphase'
,
'magphase'
,
...
@@ -353,7 +353,7 @@ def mu_law_encoding(x, quantization_channels):
...
@@ -353,7 +353,7 @@ def mu_law_encoding(x, quantization_channels):
@
torch
.
jit
.
script
@
torch
.
jit
.
script
def
mu_law_
expan
ding
(
x_mu
,
quantization_channels
):
def
mu_law_
deco
ding
(
x_mu
,
quantization_channels
):
# type: (Tensor, int) -> Tensor
# type: (Tensor, int) -> Tensor
r
"""Decode mu-law encoded signal. For more info see the
r
"""Decode mu-law encoded signal. For more info see the
`Wikipedia Entry <https://en.wikipedia.org/wiki/%CE%9C-law_algorithm>`_
`Wikipedia Entry <https://en.wikipedia.org/wiki/%CE%9C-law_algorithm>`_
...
...
torchaudio/transforms.py
View file @
6a43e9eb
...
@@ -321,7 +321,7 @@ class MuLawEncoding(torch.jit.ScriptModule):
...
@@ -321,7 +321,7 @@ class MuLawEncoding(torch.jit.ScriptModule):
return
F
.
mu_law_encoding
(
x
,
self
.
quantization_channels
)
return
F
.
mu_law_encoding
(
x
,
self
.
quantization_channels
)
class
MuLaw
Expan
ding
(
torch
.
jit
.
ScriptModule
):
class
MuLaw
Deco
ding
(
torch
.
jit
.
ScriptModule
):
r
"""Decode mu-law encoded signal. For more info see the
r
"""Decode mu-law encoded signal. For more info see the
`Wikipedia Entry <https://en.wikipedia.org/wiki/%CE%9C-law_algorithm>`_
`Wikipedia Entry <https://en.wikipedia.org/wiki/%CE%9C-law_algorithm>`_
...
@@ -334,7 +334,7 @@ class MuLawExpanding(torch.jit.ScriptModule):
...
@@ -334,7 +334,7 @@ class MuLawExpanding(torch.jit.ScriptModule):
__constants__
=
[
'quantization_channels'
]
__constants__
=
[
'quantization_channels'
]
def
__init__
(
self
,
quantization_channels
=
256
):
def
__init__
(
self
,
quantization_channels
=
256
):
super
(
MuLaw
Expan
ding
,
self
).
__init__
()
super
(
MuLaw
Deco
ding
,
self
).
__init__
()
self
.
quantization_channels
=
quantization_channels
self
.
quantization_channels
=
quantization_channels
@
torch
.
jit
.
script_method
@
torch
.
jit
.
script_method
...
@@ -346,7 +346,7 @@ class MuLawExpanding(torch.jit.ScriptModule):
...
@@ -346,7 +346,7 @@ class MuLawExpanding(torch.jit.ScriptModule):
Returns:
Returns:
torch.Tensor: The signal decoded
torch.Tensor: The signal decoded
"""
"""
return
F
.
mu_law_
expan
ding
(
x_mu
,
self
.
quantization_channels
)
return
F
.
mu_law_
deco
ding
(
x_mu
,
self
.
quantization_channels
)
class
Resample
(
torch
.
nn
.
Module
):
class
Resample
(
torch
.
nn
.
Module
):
...
...
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