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
38287a75
"docs/source/api/vscode:/vscode.git/clone" did not exist on "b3d3a2c4b0e04320bd9c0cedeb7ed70813d2d824"
Unverified
Commit
38287a75
authored
Apr 22, 2020
by
moto
Committed by
GitHub
Apr 22, 2020
Browse files
Only initialize sox once and never shutdown in test (#562)
parent
9d40302d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
12 deletions
+14
-12
test/common_utils.py
test/common_utils.py
+11
-0
test/test_dataloader.py
test/test_dataloader.py
+2
-7
test/test_sox_effects.py
test/test_sox_effects.py
+1
-5
No files found.
test/common_utils.py
View file @
38287a75
...
@@ -78,3 +78,14 @@ def filter_backends_with_mp3(backends):
...
@@ -78,3 +78,14 @@ def filter_backends_with_mp3(backends):
BACKENDS_MP3
=
filter_backends_with_mp3
(
BACKENDS
)
BACKENDS_MP3
=
filter_backends_with_mp3
(
BACKENDS
)
_IS_SOX_INITIALIZED
=
False
def
initialize_sox
():
"""Initialize sox backend only if it has not yet."""
global
_IS_SOX_INITIALIZED
if
not
_IS_SOX_INITIALIZED
:
torchaudio
.
initialize_sox
()
_IS_SOX_INITIALIZED
=
True
test/test_dataloader.py
View file @
38287a75
...
@@ -7,9 +7,7 @@ import common_utils
...
@@ -7,9 +7,7 @@ import common_utils
from
common_utils
import
AudioBackendScope
,
BACKENDS
from
common_utils
import
AudioBackendScope
,
BACKENDS
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
class
TORCHAUDIODS
(
Dataset
):
class
TORCHAUDIODS
(
Dataset
):
def
__init__
(
self
):
def
__init__
(
self
):
sound_files
=
[
"sinewave.wav"
,
"steam-train-whistle-daniel_simon.mp3"
]
sound_files
=
[
"sinewave.wav"
,
"steam-train-whistle-daniel_simon.mp3"
]
self
.
data
=
[
common_utils
.
get_asset_path
(
fn
)
for
fn
in
sound_files
]
self
.
data
=
[
common_utils
.
get_asset_path
(
fn
)
for
fn
in
sound_files
]
...
@@ -34,11 +32,7 @@ class TORCHAUDIODS(Dataset):
...
@@ -34,11 +32,7 @@ class TORCHAUDIODS(Dataset):
class
Test_DataLoader
(
unittest
.
TestCase
):
class
Test_DataLoader
(
unittest
.
TestCase
):
@
classmethod
@
classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
torchaudio
.
initialize_sox
()
common_utils
.
initialize_sox
()
@
classmethod
def
tearDownClass
(
cls
):
torchaudio
.
shutdown_sox
()
def
test_1
(
self
):
def
test_1
(
self
):
expected_size
=
(
2
,
1
,
16000
)
expected_size
=
(
2
,
1
,
16000
)
...
@@ -47,6 +41,7 @@ class Test_DataLoader(unittest.TestCase):
...
@@ -47,6 +41,7 @@ class Test_DataLoader(unittest.TestCase):
for
x
in
dl
:
for
x
in
dl
:
self
.
assertTrue
(
x
.
size
()
==
expected_size
)
self
.
assertTrue
(
x
.
size
()
==
expected_size
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
with
AudioBackendScope
(
"sox"
):
with
AudioBackendScope
(
"sox"
):
unittest
.
main
()
unittest
.
main
()
test/test_sox_effects.py
View file @
38287a75
...
@@ -13,11 +13,7 @@ class Test_SoxEffectsChain(unittest.TestCase):
...
@@ -13,11 +13,7 @@ class Test_SoxEffectsChain(unittest.TestCase):
@
classmethod
@
classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
torchaudio
.
initialize_sox
()
common_utils
.
initialize_sox
()
@
classmethod
def
tearDownClass
(
cls
):
torchaudio
.
shutdown_sox
()
def
test_single_channel
(
self
):
def
test_single_channel
(
self
):
fn_sine
=
common_utils
.
get_asset_path
(
"sinewave.wav"
)
fn_sine
=
common_utils
.
get_asset_path
(
"sinewave.wav"
)
...
...
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