@@ -293,9 +293,31 @@ sox_signalinfo_t get_signalinfo(
293293
294294sox_encodinginfo_t  get_tensor_encodinginfo (
295295    const  caffe2::TypeMeta dtype) {
296+   sox_encoding_t  encoding = [&](){
297+     if  (dtype == torch::kUInt8 )
298+       return  SOX_ENCODING_UNSIGNED;
299+     if  (dtype == torch::kInt16 )
300+       return  SOX_ENCODING_SIGN2;
301+     if  (dtype == torch::kInt32 )
302+       return  SOX_ENCODING_SIGN2;
303+     if  (dtype == torch::kFloat32 )
304+       return  SOX_ENCODING_FLOAT;
305+     throw  std::runtime_error (" Unsupported dtype." 
306+   }();
307+   unsigned  bits_per_sample = [&](){
308+     if  (dtype == torch::kUInt8 )
309+       return  8 ;
310+     if  (dtype == torch::kInt16 )
311+       return  16 ;
312+     if  (dtype == torch::kInt32 )
313+       return  32 ;
314+     if  (dtype == torch::kFloat32 )
315+       return  32 ;
316+     throw  std::runtime_error (" Unsupported dtype." 
317+   }();
296318  return  sox_encodinginfo_t {
297-       /* encoding=*/ get_encoding ( " wav " , dtype) ,
298-       /* bits_per_sample=*/ get_precision ( " wav " , dtype) ,
319+       /* encoding=*/ encoding ,
320+       /* bits_per_sample=*/ bits_per_sample ,
299321      /* compression=*/ 
300322      /* reverse_bytes=*/ 
301323      /* reverse_nibbles=*/ 
0 commit comments