Skip to content

Commit

Permalink
Revert "Remove BC code"
Browse files Browse the repository at this point in the history
This reverts commit abbb52e.
  • Loading branch information
mthrok committed Aug 31, 2020
1 parent 47aee13 commit 1e722d8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion torchaudio/backend/sox_io_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def load(
``[channel, time]`` else ``[time, channel]``.
"""
sample_rate = -1 if sample_rate is None else sample_rate
signal = torch.ops.torchaudio.sox_io_load_audio_file(
signal = torch.ops.torchaudio.sox_io_load_audio_file_v1(
filepath, frame_offset, num_frames, normalize, channels_first, sample_rate)
return signal.get_tensor(), signal.get_sample_rate()

Expand Down
3 changes: 3 additions & 0 deletions torchaudio/csrc/register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ TORCH_LIBRARY(torchaudio, m) {
m.def(
"torchaudio::sox_io_load_audio_file",
&torchaudio::sox_io::load_audio_file);
m.def(
"torchaudio::sox_io_load_audio_file_v1",
&torchaudio::sox_io::load_audio_file_v1);
m.def(
"torchaudio::sox_io_save_audio_file",
&torchaudio::sox_io::save_audio_file);
Expand Down
9 changes: 9 additions & 0 deletions torchaudio/csrc/sox_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ c10::intrusive_ptr<SignalInfo> get_info(const std::string& path) {
}

c10::intrusive_ptr<TensorSignal> load_audio_file(
const std::string& path,
const int64_t frame_offset,
const int64_t num_frames,
const bool normalize,
const bool channels_first) {
return load_audio_file_v1(path, frame_offset, num_frames, channels_first, -1);
}

c10::intrusive_ptr<TensorSignal> load_audio_file_v1(
const std::string& path,
const int64_t frame_offset,
const int64_t num_frames,
Expand Down
9 changes: 9 additions & 0 deletions torchaudio/csrc/sox_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ struct SignalInfo : torch::CustomClassHolder {

c10::intrusive_ptr<SignalInfo> get_info(const std::string& path);

// ver. 0
c10::intrusive_ptr<torchaudio::sox_utils::TensorSignal> load_audio_file(
const std::string& path,
const int64_t frame_offset = 0,
const int64_t num_frames = -1,
const bool normalize = true,
const bool channels_first = true);

// ver. 1 sample_rate is added
c10::intrusive_ptr<torchaudio::sox_utils::TensorSignal> load_audio_file_v1(
const std::string& path,
const int64_t frame_offset = 0,
const int64_t num_frames = -1,
Expand Down

0 comments on commit 1e722d8

Please sign in to comment.