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
20f34c6c
"torchvision/vscode:/vscode.git/clone" did not exist on "88d18d66e96e056eadc1d476cfeed6b598306095"
Commit
20f34c6c
authored
Oct 09, 2017
by
Raffaele Sena
Browse files
Quick and dirty fix for "bytes" not available in python2
parent
9edce71c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
torchaudio/__init__.py
torchaudio/__init__.py
+7
-1
No files found.
torchaudio/__init__.py
View file @
20f34c6c
import
os
import
sys
import
torch
...
...
@@ -10,6 +11,11 @@ from ._ext import th_sox
from
torchaudio
import
transforms
from
torchaudio
import
datasets
if
sys
.
version_info
>=
(
3
,
0
):
_bytes
=
bytes
else
:
_bytes
=
lambda
s
,
e
:
s
.
encode
(
e
)
def
check_input
(
src
):
if
not
torch
.
is_tensor
(
src
):
raise
TypeError
(
'Expected a tensor, got %s'
%
type
(
src
))
...
...
@@ -64,4 +70,4 @@ def save(filepath, src, sample_rate):
check_input
(
src
)
typename
=
type
(
src
).
__name__
.
replace
(
'Tensor'
,
''
)
func
=
getattr
(
th_sox
,
'libthsox_{}_write_audio_file'
.
format
(
typename
))
func
(
bytes
(
filepath
,
"utf-8"
),
src
,
bytes
(
extension
[
1
:],
"utf-8"
),
sample_rate
)
func
(
_
bytes
(
filepath
,
"utf-8"
),
src
,
_
bytes
(
extension
[
1
:],
"utf-8"
),
sample_rate
)
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