You need to sign in or sign up before continuing.
Unverified Commit d2861fc2 authored by SJ's avatar SJ Committed by GitHub
Browse files

Check for the number of channels in an htk file being 1 (#1291)

parent 5c017957
...@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment