diff --git a/test/torchaudio_unittest/sox_io_backend/load_test.py b/test/torchaudio_unittest/sox_io_backend/load_test.py index 5428d5dbb1e..c5be324c83b 100644 --- a/test/torchaudio_unittest/sox_io_backend/load_test.py +++ b/test/torchaudio_unittest/sox_io_backend/load_test.py @@ -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}') @@ -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_: diff --git a/torchaudio/csrc/sox/effects_chain.cpp b/torchaudio/csrc/sox/effects_chain.cpp index 769c6c57e7f..b4c15755419 100644 --- a/torchaudio/csrc/sox/effects_chain.cpp +++ b/torchaudio/csrc/sox/effects_chain.cpp @@ -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->| // |**********|-----------------|++++++++++++|