Skip to content

Commit bea8d82

Browse files
committed
Merge branch 'remove_backends' into remove_io_dir
2 parents 50a538a + 9ab06f7 commit bea8d82

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/torchaudio/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@
3333
from torchaudio.utils import wav_utils
3434
def load(
3535
uri: str,
36+
frame_offset: int = 0,
37+
num_frames: int = -1,
3638
normalize: bool = True,
3739
channels_first: bool = True,
3840
) -> Tuple[torch.Tensor, int]:
39-
return wav_utils.load_wav(uri, normalize, channels_first)
41+
data, sample_rate = wav_utils.load_wav(uri, normalize, channels_first=False)
42+
if num_frames == -1:
43+
num_frames = data.shape[0] - frame_offset
44+
data = data[frame_offset:frame_offset+num_frames]
45+
if channels_first:
46+
data = data.transpose(0, 1)
47+
return data, sample_rate
4048

4149
def save(
4250
uri: str,

0 commit comments

Comments
 (0)