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
70328527
Unverified
Commit
70328527
authored
Dec 03, 2019
by
Vincent QB
Committed by
GitHub
Dec 03, 2019
Browse files
remove scale to interval from #319 (#360)
parent
38f1e870
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
34 deletions
+0
-34
test/test_functional.py
test/test_functional.py
+0
-13
torchaudio/functional.py
torchaudio/functional.py
+0
-21
No files found.
test/test_functional.py
View file @
70328527
...
@@ -379,13 +379,6 @@ class TestFunctional(unittest.TestCase):
...
@@ -379,13 +379,6 @@ class TestFunctional(unittest.TestCase):
self
.
assertTrue
(
torch
.
allclose
(
waveform_gain
,
sox_gain_waveform
,
atol
=
1e-04
))
self
.
assertTrue
(
torch
.
allclose
(
waveform_gain
,
sox_gain_waveform
,
atol
=
1e-04
))
def
test_scale_to_interval
(
self
):
scaled
=
5.5
# [-5.5, 5.5]
waveform_scaled
=
F
.
_scale_to_interval
(
self
.
waveform_train
,
scaled
)
self
.
assertTrue
(
torch
.
max
(
waveform_scaled
)
<=
scaled
)
self
.
assertTrue
(
torch
.
min
(
waveform_scaled
)
>=
-
scaled
)
def
test_dither
(
self
):
def
test_dither
(
self
):
waveform_dithered
=
F
.
dither
(
self
.
waveform_train
)
waveform_dithered
=
F
.
dither
(
self
.
waveform_train
)
waveform_dithered_noiseshaped
=
F
.
dither
(
self
.
waveform_train
,
noise_shaping
=
True
)
waveform_dithered_noiseshaped
=
F
.
dither
(
self
.
waveform_train
,
noise_shaping
=
True
)
...
@@ -582,12 +575,6 @@ def test_phase_vocoder(complex_specgrams, rate, hop_length):
...
@@ -582,12 +575,6 @@ def test_phase_vocoder(complex_specgrams, rate, hop_length):
_test_torchscript_functional
(
F
.
gain
,
tensor
,
gainDB
)
_test_torchscript_functional
(
F
.
gain
,
tensor
,
gainDB
)
def
test_torchscript_scale_to_interval
(
self
):
tensor
=
torch
.
rand
((
1
,
1000
))
scaled
=
3.5
_test_torchscript_functional
(
F
.
_scale_to_interval
,
tensor
,
scaled
)
def
test_torchscript_dither
(
self
):
def
test_torchscript_dither
(
self
):
tensor
=
torch
.
rand
((
1
,
1000
))
tensor
=
torch
.
rand
((
1
,
1000
))
...
...
torchaudio/functional.py
View file @
70328527
...
@@ -877,27 +877,6 @@ def gain(waveform, gain_db=1.0):
...
@@ -877,27 +877,6 @@ def gain(waveform, gain_db=1.0):
return
waveform
*
ratio
return
waveform
*
ratio
def
_scale_to_interval
(
waveform
,
interval_max
=
1.0
):
# type: (Tensor, float) -> Tensor
r
"""Scale the waveform to the interval [-interval_max, interval_max] across all dimensions.
Args:
waveform (torch.Tensor): Tensor of audio of dimension (channel, time).
interval_max (float): The bounds of the interval, where the float indicates
the upper bound and the negative of the float indicates the lower
bound (Default: `1.0`).
Example: interval=1.0 -> [-1.0, 1.0]
Returns:
torch.Tensor: the whole waveform scaled to interval.
"""
abs_max
=
torch
.
max
(
torch
.
abs
(
waveform
))
ratio
=
abs_max
/
interval_max
waveform
/=
ratio
return
waveform
def
_add_noise_shaping
(
dithered_waveform
,
waveform
):
def
_add_noise_shaping
(
dithered_waveform
,
waveform
):
r
"""Noise shaping is calculated by error:
r
"""Noise shaping is calculated by error:
error[n] = dithered[n] - original[n]
error[n] = dithered[n] - original[n]
...
...
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