Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mthrok committed Jan 22, 2021
1 parent b6d4ed3 commit cbaa492
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions test/torchaudio_unittest/sox_io_backend/load_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,10 @@ def test_bytesio(self, ext, compression):
('amb', None),
])
def test_bytesio_clogged(self, ext, compression):
"""Loading audio via BytesIO object returns the same result as via file path."""
"""Loading audio via clogged file object returns the same result as via file path.
This test case validates the case where fileobject returns shorter bytes than requeted.
"""
sample_rate = 16000
format_ = ext if ext in ['mp3'] else None
path = self.get_temp_path(f'test.{ext}')
Expand Down Expand Up @@ -498,14 +501,15 @@ def test_bytesio_clogged(self, ext, compression):
('amb', None),
])
def test_bytesio_tiny(self, ext, compression):
"""Loading audio via BytesIO object returns the same result as via file path."""
"""Loading very small audio via file object returns the same result as via file path.
"""
sample_rate = 16000
format_ = ext if ext in ['mp3'] else None
path = self.get_temp_path(f'test.{ext}')

sox_utils.gen_audio_file(
path, sample_rate, num_channels=2,
compression=compression, duration=1 / 1600)
compression=compression, duration=1 / 16000)
expected, _ = sox_io_backend.load(path)

with open(path, 'rb') as file_:
Expand Down
4 changes: 2 additions & 2 deletions torchaudio/csrc/sox/effects_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ int fileobj_input_drain(sox_effect_t* effp, sox_sample_t* obuf, size_t* osamp) {
// |<-------consumed------>|<---remaining--->|
// |***********************|-----------------|
// ^ ftell
//
// After:
//
// After:
//
// |<-offset->|<---remaining--->|<-new data->|
// |**********|-----------------|++++++++++++|
Expand Down

0 comments on commit cbaa492

Please sign in to comment.