Skip to content

Commit 265bc5c

Browse files
authored
Fix incorrect audio trimming with negative index
Differential Revision: D67155973 Pull Request resolved: #3860
1 parent 332760d commit 265bc5c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/torchaudio/functional/filtering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,6 @@ def vad(
16651665
if not has_triggered:
16661666
return waveform[..., :0].view(shape[:-1] + torch.Size([0]))
16671667

1668-
res = waveform[:, pos - samplesLen_ns + flushedLen_ns :]
1668+
res = waveform[:, max(pos - samplesLen_ns + flushedLen_ns, 0) :]
16691669
# unpack batch
16701670
return res.view(shape[:-1] + res.shape[-1:])

0 commit comments

Comments
 (0)