diff --git a/src/torchaudio/functional/filtering.py b/src/torchaudio/functional/filtering.py index 97ff6040dc..1628d82c33 100644 --- a/src/torchaudio/functional/filtering.py +++ b/src/torchaudio/functional/filtering.py @@ -1665,6 +1665,6 @@ def vad( if not has_triggered: return waveform[..., :0].view(shape[:-1] + torch.Size([0])) - res = waveform[:, pos - samplesLen_ns + flushedLen_ns :] + res = waveform[:, max(pos - samplesLen_ns + flushedLen_ns, 0) :] # unpack batch return res.view(shape[:-1] + res.shape[-1:])