Skip to content

Commit 34878e1

Browse files
committed
Fix SignalInfo member name to frame
1 parent 88fccd1 commit 34878e1

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

test/sox_io_backend/test_info.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_wav(self, dtype, sample_rate, num_channels):
3535
)
3636
info = sox_io_backend.info(path)
3737
assert info.get_sample_rate() == sample_rate
38-
assert info.get_num_samples() == sample_rate * duration
38+
assert info.get_num_frames() == sample_rate * duration
3939
assert info.get_num_channels() == num_channels
4040

4141
@parameterized.expand(list(itertools.product(
@@ -55,7 +55,7 @@ def test_wav_multiple_channels(self, dtype, sample_rate, num_channels):
5555
)
5656
info = sox_io_backend.info(path)
5757
assert info.get_sample_rate() == sample_rate
58-
assert info.get_num_samples() == sample_rate * duration
58+
assert info.get_num_frames() == sample_rate * duration
5959
assert info.get_num_channels() == num_channels
6060

6161
@parameterized.expand(list(itertools.product(
@@ -74,7 +74,7 @@ def test_mp3(self, sample_rate, num_channels, bit_rate):
7474
info = sox_io_backend.info(path)
7575
assert info.get_sample_rate() == sample_rate
7676
# mp3 does not preserve the number of samples
77-
# assert info.get_num_samples() == sample_rate * duration
77+
# assert info.get_num_frames() == sample_rate * duration
7878
assert info.get_num_channels() == num_channels
7979

8080
@parameterized.expand(list(itertools.product(
@@ -92,7 +92,7 @@ def test_flac(self, sample_rate, num_channels, compression_level):
9292
)
9393
info = sox_io_backend.info(path)
9494
assert info.get_sample_rate() == sample_rate
95-
assert info.get_num_samples() == sample_rate * duration
95+
assert info.get_num_frames() == sample_rate * duration
9696
assert info.get_num_channels() == num_channels
9797

9898
@parameterized.expand(list(itertools.product(
@@ -110,5 +110,5 @@ def test_vorbis(self, sample_rate, num_channels, quality_level):
110110
)
111111
info = sox_io_backend.info(path)
112112
assert info.get_sample_rate() == sample_rate
113-
assert info.get_num_samples() == sample_rate * duration
113+
assert info.get_num_frames() == sample_rate * duration
114114
assert info.get_num_channels() == num_channels

test/sox_io_backend/test_torchscript.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ def test_info_wav(self, dtype, sample_rate, num_channels):
4444
ts_info = ts_info_func(audio_path)
4545

4646
assert py_info.get_sample_rate() == ts_info.get_sample_rate()
47-
assert py_info.get_num_samples() == ts_info.get_num_samples()
47+
assert py_info.get_num_frames() == ts_info.get_num_frames()
4848
assert py_info.get_num_channels() == ts_info.get_num_channels()

torchaudio/csrc/register.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static auto registerSignalInfo =
1212
.def(torch::init<int64_t, int64_t, int64_t>())
1313
.def("get_sample_rate", &SignalInfo::getSampleRate)
1414
.def("get_num_channels", &SignalInfo::getNumChannels)
15-
.def("get_num_samples", &SignalInfo::getNumSamples);
15+
.def("get_num_frames", &SignalInfo::getNumFrames);
1616

1717
static auto registerGetInfo = torch::RegisterOperators().op(
1818
torch::RegisterOperators::options()

torchaudio/csrc/typedefs.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ namespace torchaudio {
44
SignalInfo::SignalInfo(
55
const int64_t sample_rate_,
66
const int64_t num_channels_,
7-
const int64_t num_samples_)
7+
const int64_t num_frames_)
88
: sample_rate(sample_rate_),
99
num_channels(num_channels_),
10-
num_samples(num_samples_){};
10+
num_frames(num_frames_){};
1111

1212
int64_t SignalInfo::getSampleRate() const {
1313
return sample_rate;
@@ -17,7 +17,7 @@ int64_t SignalInfo::getNumChannels() const {
1717
return num_channels;
1818
}
1919

20-
int64_t SignalInfo::getNumSamples() const {
21-
return num_samples;
20+
int64_t SignalInfo::getNumFrames() const {
21+
return num_frames;
2222
}
2323
} // namespace torchaudio

torchaudio/csrc/typedefs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ namespace torchaudio {
77
struct SignalInfo : torch::CustomClassHolder {
88
int64_t sample_rate;
99
int64_t num_channels;
10-
int64_t num_samples;
10+
int64_t num_frames;
1111

1212
SignalInfo(
1313
const int64_t sample_rate_,
1414
const int64_t num_channels_,
15-
const int64_t num_samples_);
15+
const int64_t num_frames_);
1616
int64_t getSampleRate() const;
1717
int64_t getNumChannels() const;
18-
int64_t getNumSamples() const;
18+
int64_t getNumFrames() const;
1919
};
2020

2121
} // namespace torchaudio

torchaudio/extension/extension.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ class SignalInfo:
3030
without extension.
3131
This class has to implement the same interface as C++ equivalent.
3232
"""
33-
def __init__(self, sample_rate: int, num_channels: int, num_samples: int):
33+
def __init__(self, sample_rate: int, num_channels: int, num_frames: int):
3434
self.sample_rate = sample_rate
3535
self.num_channels = num_channels
36-
self.num_samples = num_samples
36+
self.num_frames = num_frames
3737

3838
def get_sample_rate(self):
3939
return self.sample_rate
4040

4141
def get_num_channels(self):
4242
return self.num_channels
4343

44-
def get_num_samples(self):
45-
return self.num_samples
44+
def get_num_frames(self):
45+
return self.num_frames
4646

4747
DummyModule = namedtuple('torchaudio', ['SignalInfo'])
4848
module = DummyModule(SignalInfo)

0 commit comments

Comments
 (0)