Commit 3f9b5171 authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Fix save INT16 sox backend (#3524)

Summary:
When passing int16 type tensor to `save(backend="sox")`, the resulting file should be 16-bit signed PCM, but instead is 32-bit signed PCM.

Resolves https://github.com/pytorch/audio/issues/3304

Pull Request resolved: https://github.com/pytorch/audio/pull/3524

Reviewed By: huangruizhe

Differential Revision: D47941090

Pulled By: mthrok

fbshipit-source-id: 2622b31eb1cbf03969f67ab2b2adec6e2ba677c4
parent 732c94a3
......@@ -222,7 +222,7 @@ std::tuple<sox_encoding_t, unsigned> get_save_encoding_for_wav(
case Encoding::PCM_SIGNED:
switch (bits_per_sample) {
case BitDepth::NOT_PROVIDED:
return std::make_tuple<>(SOX_ENCODING_SIGN2, 32);
return std::make_tuple<>(SOX_ENCODING_SIGN2, 16);
case BitDepth::B8:
TORCH_CHECK(
false, format, " does not support 8-bit signed PCM encoding.");
......
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