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
e3642896
Unverified
Commit
e3642896
authored
Jun 08, 2020
by
moto
Committed by
GitHub
Jun 08, 2020
Browse files
Add backend module and isolate backend-related functionalities (#700)
parent
2fd32dd0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
10 deletions
+28
-10
test/common_utils.py
test/common_utils.py
+1
-1
torchaudio/__init__.py
torchaudio/__init__.py
+4
-4
torchaudio/backend/__init__.py
torchaudio/backend/__init__.py
+18
-0
torchaudio/backend/soundfile_backend.py
torchaudio/backend/soundfile_backend.py
+0
-0
torchaudio/backend/sox_backend.py
torchaudio/backend/sox_backend.py
+2
-2
torchaudio/backend/utils.py
torchaudio/backend/utils.py
+3
-3
No files found.
test/common_utils.py
View file @
e3642896
...
@@ -10,7 +10,7 @@ from torch.testing._internal.common_utils import TestCase
...
@@ -10,7 +10,7 @@ from torch.testing._internal.common_utils import TestCase
import
torchaudio
import
torchaudio
_TEST_DIR_PATH
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
_TEST_DIR_PATH
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
BACKENDS
=
torchaudio
.
_backend
.
_BACKENDS
BACKENDS
=
torchaudio
.
list_audio_backends
()
def
get_asset_path
(
*
paths
):
def
get_asset_path
(
*
paths
):
...
...
torchaudio/__init__.py
View file @
e3642896
...
@@ -9,20 +9,20 @@ from torchaudio import (
...
@@ -9,20 +9,20 @@ from torchaudio import (
sox_effects
,
sox_effects
,
transforms
transforms
)
)
from
torchaudio.
_
backend
import
(
from
torchaudio.backend
import
(
_get_audio_backend_module
,
_get_audio_backend_module
,
list_audio_backends
,
get_audio_backend
,
get_audio_backend
,
set_audio_backend
,
set_audio_backend
,
)
from
torchaudio._sox_backend
import
(
save_encinfo
,
save_encinfo
,
sox_signalinfo_t
,
sox_signalinfo_t
,
sox_encodinginfo_t
,
sox_encodinginfo_t
,
get_sox_option_t
,
get_sox_option_t
,
get_sox_encoding_t
,
get_sox_encoding_t
,
get_sox_bool
,
get_sox_bool
,
SignalInfo
,
EncodingInfo
,
)
)
from
torchaudio._soundfile_backend
import
SignalInfo
,
EncodingInfo
from
torchaudio._internal
import
(
from
torchaudio._internal
import
(
module_utils
as
_mod_utils
,
module_utils
as
_mod_utils
,
misc_ops
as
_misc_ops
,
misc_ops
as
_misc_ops
,
...
...
torchaudio/backend/__init__.py
0 → 100644
View file @
e3642896
from
.utils
import
(
_get_audio_backend_module
,
list_audio_backends
,
get_audio_backend
,
set_audio_backend
,
)
from
.sox_backend
import
(
save_encinfo
,
sox_signalinfo_t
,
sox_encodinginfo_t
,
get_sox_option_t
,
get_sox_encoding_t
,
get_sox_bool
,
)
from
.soundfile_backend
import
(
SignalInfo
,
EncodingInfo
,
)
torchaudio/
_
soundfile_backend.py
→
torchaudio/
backend/
soundfile_backend.py
View file @
e3642896
File moved
torchaudio/
_
sox_backend.py
→
torchaudio/
backend/
sox_backend.py
View file @
e3642896
...
@@ -8,10 +8,10 @@ from torchaudio._internal import (
...
@@ -8,10 +8,10 @@ from torchaudio._internal import (
module_utils
as
_mod_utils
,
module_utils
as
_mod_utils
,
misc_ops
as
_misc_ops
,
misc_ops
as
_misc_ops
,
)
)
from
torchaudio._
soundfile_backend
import
SignalInfo
,
EncodingInfo
from
.
soundfile_backend
import
SignalInfo
,
EncodingInfo
if
_mod_utils
.
is_module_available
(
'torchaudio._torchaudio'
):
if
_mod_utils
.
is_module_available
(
'torchaudio._torchaudio'
):
from
.
import
_torchaudio
from
torchaudio
import
_torchaudio
@
_mod_utils
.
requires_module
(
'torchaudio._torchaudio'
)
@
_mod_utils
.
requires_module
(
'torchaudio._torchaudio'
)
...
...
torchaudio/
_
backend.py
→
torchaudio/backend
/utils
.py
View file @
e3642896
from
typing
import
Any
,
Optional
from
typing
import
Any
,
Optional
from
torchaudio._internal
import
module_utils
as
_mod_utils
from
torchaudio._internal
import
module_utils
as
_mod_utils
from
.
import
_
soundfile_backend
,
_
sox_backend
from
.
import
soundfile_backend
,
sox_backend
_BACKEND
=
None
_BACKEND
=
None
_BACKENDS
=
{}
_BACKENDS
=
{}
if
_mod_utils
.
is_module_available
(
'soundfile'
):
if
_mod_utils
.
is_module_available
(
'soundfile'
):
_BACKENDS
[
'soundfile'
]
=
_
soundfile_backend
_BACKENDS
[
'soundfile'
]
=
soundfile_backend
if
_mod_utils
.
is_module_available
(
'torchaudio._torchaudio'
):
if
_mod_utils
.
is_module_available
(
'torchaudio._torchaudio'
):
_BACKENDS
[
'sox'
]
=
_
sox_backend
_BACKENDS
[
'sox'
]
=
sox_backend
if
'sox'
in
_BACKENDS
:
if
'sox'
in
_BACKENDS
:
_BACKEND
=
'sox'
_BACKEND
=
'sox'
...
...
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