sox_io.h 1.02 KB
Newer Older
moto's avatar
moto committed
1
2
3
#ifndef TORCHAUDIO_SOX_IO_H
#define TORCHAUDIO_SOX_IO_H

4
#include <torch/script.h>
moto's avatar
moto committed
5
#include <torchaudio/csrc/sox_utils.h>
6
7
8
9

namespace torchaudio {
namespace sox_io {

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
struct SignalInfo : torch::CustomClassHolder {
  int64_t sample_rate;
  int64_t num_channels;
  int64_t num_frames;

  SignalInfo(
      const int64_t sample_rate_,
      const int64_t num_channels_,
      const int64_t num_frames_);
  int64_t getSampleRate() const;
  int64_t getNumChannels() const;
  int64_t getNumFrames() const;
};

c10::intrusive_ptr<SignalInfo> get_info(const std::string& path);
moto's avatar
moto committed
25
26
27
28
29
30
31

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);
32

33
34
35
void save_audio_file(
    const std::string& file_name,
    const c10::intrusive_ptr<torchaudio::sox_utils::TensorSignal>& signal,
36
37
    const double compression = 0.);

38
39
} // namespace sox_io
} // namespace torchaudio
moto's avatar
moto committed
40
41

#endif