Skip to content

Commit

Permalink
Fix incorrect audio trimming with negative index
Browse files Browse the repository at this point in the history
Differential Revision: D67155973

Pull Request resolved: #3860
  • Loading branch information
RoyJames authored Dec 13, 2024
1 parent 332760d commit 265bc5c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/torchaudio/functional/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:])

0 comments on commit 265bc5c

Please sign in to comment.