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
d2861fc2
You need to sign in or sign up before continuing.
Unverified
Commit
d2861fc2
authored
Feb 19, 2021
by
SJ
Committed by
GitHub
Feb 19, 2021
Browse files
Check for the number of channels in an htk file being 1 (#1291)
parent
5c017957
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
torchaudio/csrc/sox/io.cpp
torchaudio/csrc/sox/io.cpp
+10
-0
No files found.
torchaudio/csrc/sox/io.cpp
View file @
d2861fc2
...
@@ -132,6 +132,10 @@ void save_audio_file(
...
@@ -132,6 +132,10 @@ void save_audio_file(
const
auto
num_channels
=
tensor
.
size
(
channels_first
?
0
:
1
);
const
auto
num_channels
=
tensor
.
size
(
channels_first
?
0
:
1
);
TORCH_CHECK
(
TORCH_CHECK
(
num_channels
==
1
,
"amr-nb format only supports single channel audio."
);
num_channels
==
1
,
"amr-nb format only supports single channel audio."
);
}
else
if
(
filetype
==
"htk"
)
{
const
auto
num_channels
=
tensor
.
size
(
channels_first
?
0
:
1
);
TORCH_CHECK
(
num_channels
==
1
,
"htk format only supports single channel audio."
);
}
}
const
auto
signal_info
=
const
auto
signal_info
=
get_signalinfo
(
&
tensor
,
sample_rate
,
filetype
,
channels_first
);
get_signalinfo
(
&
tensor
,
sample_rate
,
filetype
,
channels_first
);
...
@@ -268,6 +272,12 @@ void save_audio_fileobj(
...
@@ -268,6 +272,12 @@ void save_audio_fileobj(
throw
std
::
runtime_error
(
throw
std
::
runtime_error
(
"amr-nb format only supports single channel audio."
);
"amr-nb format only supports single channel audio."
);
}
}
}
else
if
(
filetype
==
"htk"
)
{
const
auto
num_channels
=
tensor
.
size
(
channels_first
?
0
:
1
);
if
(
num_channels
!=
1
)
{
throw
std
::
runtime_error
(
"htk format only supports single channel audio."
);
}
}
}
const
auto
signal_info
=
const
auto
signal_info
=
get_signalinfo
(
&
tensor
,
sample_rate
,
filetype
,
channels_first
);
get_signalinfo
(
&
tensor
,
sample_rate
,
filetype
,
channels_first
);
...
...
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