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
2a6b6b55
"integration-tests/vscode:/vscode.git/clone" did not exist on "dd2d91b043ae935f3097ce65c44403d5aa9ecc46"
Unverified
Commit
2a6b6b55
authored
Aug 07, 2020
by
moto
Committed by
GitHub
Aug 07, 2020
Browse files
Fix dither with noise_shaping = True (#865)
parent
b2f912cc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
test/torchaudio_unittest/torchscript_consistency_impl.py
test/torchaudio_unittest/torchscript_consistency_impl.py
+7
-0
torchaudio/functional.py
torchaudio/functional.py
+2
-1
No files found.
test/torchaudio_unittest/torchscript_consistency_impl.py
View file @
2a6b6b55
...
...
@@ -194,6 +194,13 @@ class Functional(common_utils.TestBaseMixin):
tensor
=
common_utils
.
get_whitenoise
(
n_channels
=
2
)
self
.
_assert_consistency
(
func
,
tensor
,
shape_only
=
True
)
def
test_dither_noise_shaping
(
self
):
def
func
(
tensor
):
return
F
.
dither
(
tensor
,
noise_shaping
=
True
)
tensor
=
common_utils
.
get_whitenoise
(
n_channels
=
2
)
self
.
_assert_consistency
(
func
,
tensor
)
def
test_lfilter
(
self
):
if
self
.
dtype
==
torch
.
float64
:
raise
unittest
.
SkipTest
(
"This test is known to fail for float64"
)
...
...
torchaudio/functional.py
View file @
2a6b6b55
...
...
@@ -1655,9 +1655,10 @@ def _add_noise_shaping(
error
=
dithered_waveform
-
waveform
# add error[n-1] to dithered_waveform[n], so offset the error by 1 index
zeros
=
torch
.
zeros
(
1
,
dtype
=
error
.
dtype
,
device
=
error
.
device
)
for
index
in
range
(
error
.
size
()[
0
]):
err
=
error
[
index
]
error_offset
=
torch
.
cat
((
torch
.
zeros
(
1
)
,
err
))
error_offset
=
torch
.
cat
((
zeros
,
err
))
error
[
index
]
=
error_offset
[:
waveform
.
size
()[
1
]]
noise_shaped
=
dithered_waveform
+
error
...
...
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