in torchaudio/csrc/sox/utils.cpp [390:423]
unsigned get_precision(const std::string filetype, caffe2::TypeMeta dtype) {
if (filetype == "mp3")
return SOX_UNSPEC;
if (filetype == "flac")
return 24;
if (filetype == "ogg" || filetype == "vorbis")
return SOX_UNSPEC;
if (filetype == "wav" || filetype == "amb") {
switch (dtype.toScalarType()) {
case c10::ScalarType::Byte:
return 8;
case c10::ScalarType::Short:
return 16;
case c10::ScalarType::Int:
return 32;
case c10::ScalarType::Float:
return 32;
default:
throw std::runtime_error("Unsupported dtype.");
}
}
if (filetype == "sph")
return 32;
if (filetype == "amr-nb") {
return 16;
}
if (filetype == "gsm") {
return 16;
}
if (filetype == "htk") {
return 16;
}
throw std::runtime_error("Unsupported file type: " + filetype);
}