Skip to content

Commit

Permalink
Fix save INT16 sox backend (#3524)
Browse files Browse the repository at this point in the history
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 #3304

Pull Request resolved: #3524

Reviewed By: huangruizhe

Differential Revision: D47941090

Pulled By: mthrok

fbshipit-source-id: 2622b31eb1cbf03969f67ab2b2adec6e2ba677c4
  • Loading branch information
mthrok authored and facebook-github-bot committed Aug 2, 2023
1 parent 732c94a commit 3f9b517
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torchaudio/csrc/sox/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down

0 comments on commit 3f9b517

Please sign in to comment.