@@ -93,7 +93,7 @@ void validate_input_file(const SoxFormat& sf, const std::string& path) {
93
93
" Error loading audio file: unknown encoding." );
94
94
}
95
95
96
- void validate_input_tensor (const torch::Tensor tensor) {
96
+ void validate_input_tensor (const torch::Tensor& tensor) {
97
97
TORCH_CHECK (tensor.device ().is_cpu (), " Input tensor has to be on CPU." );
98
98
99
99
TORCH_CHECK (tensor.ndimension () == 2 , " Input tensor has to be 2D." );
@@ -184,7 +184,7 @@ torch::Tensor convert_to_tensor(
184
184
return t.contiguous ();
185
185
}
186
186
187
- const std::string get_filetype (const std::string path) {
187
+ const std::string get_filetype (const std::string& path) {
188
188
std::string ext = path.substr (path.find_last_of (" ." ) + 1 );
189
189
std::transform (ext.begin (), ext.end (), ext.begin (), ::tolower);
190
190
return ext;
@@ -278,9 +278,9 @@ std::tuple<sox_encoding_t, unsigned> get_save_encoding_for_wav(
278
278
279
279
std::tuple<sox_encoding_t , unsigned > get_save_encoding (
280
280
const std::string& format,
281
- const caffe2::TypeMeta dtype,
282
- const c10::optional<std::string> encoding,
283
- const c10::optional<int64_t > bits_per_sample) {
281
+ const caffe2::TypeMeta& dtype,
282
+ const c10::optional<std::string>& encoding,
283
+ const c10::optional<int64_t >& bits_per_sample) {
284
284
const Format fmt = get_format_from_string (format);
285
285
const Encoding enc = get_encoding_from_option (encoding);
286
286
const BitDepth bps = get_bit_depth_from_option (bits_per_sample);
@@ -385,7 +385,7 @@ std::tuple<sox_encoding_t, unsigned> get_save_encoding(
385
385
}
386
386
}
387
387
388
- unsigned get_precision (const std::string filetype, caffe2::TypeMeta dtype) {
388
+ unsigned get_precision (const std::string& filetype, caffe2::TypeMeta dtype) {
389
389
if (filetype == " mp3" )
390
390
return SOX_UNSPEC;
391
391
if (filetype == " flac" )
@@ -425,7 +425,7 @@ unsigned get_precision(const std::string filetype, caffe2::TypeMeta dtype) {
425
425
sox_signalinfo_t get_signalinfo (
426
426
const torch::Tensor* waveform,
427
427
const int64_t sample_rate,
428
- const std::string filetype,
428
+ const std::string& filetype,
429
429
const bool channels_first) {
430
430
return sox_signalinfo_t {
431
431
/* rate=*/ static_cast <sox_rate_t >(sample_rate),
@@ -476,10 +476,10 @@ sox_encodinginfo_t get_tensor_encodinginfo(caffe2::TypeMeta dtype) {
476
476
477
477
sox_encodinginfo_t get_encodinginfo_for_save (
478
478
const std::string& format,
479
- const caffe2::TypeMeta dtype,
480
- const c10::optional<double > compression,
481
- const c10::optional<std::string> encoding,
482
- const c10::optional<int64_t > bits_per_sample) {
479
+ const caffe2::TypeMeta& dtype,
480
+ const c10::optional<double >& compression,
481
+ const c10::optional<std::string>& encoding,
482
+ const c10::optional<int64_t >& bits_per_sample) {
483
483
auto enc = get_save_encoding (format, dtype, encoding, bits_per_sample);
484
484
return sox_encodinginfo_t {
485
485
/* encoding=*/ std::get<0 >(enc),
0 commit comments