Skip to content
Snippets Groups Projects
Unverified Commit 28d0b9f3 authored by Gaspard Petit's avatar Gaspard Petit Committed by GitHub
Browse files

Fix for issue 2334 : VAD fails on short audio (#2335)

* Fix for issue 2334 : VAD fails on short audio

* Fix off-by-one boundary logic in VAD processing
parent b7f4c52e
No related branches found
No related tags found
No related merge requests found
...@@ -109,6 +109,10 @@ class VAD(Pretrained): ...@@ -109,6 +109,10 @@ class VAD(Pretrained):
last_chunk = False last_chunk = False
begin_sample = 0 begin_sample = 0
while True: while True:
# Check if the current chunk is the last one
if begin_sample + long_chunk_len >= audio_len:
last_chunk = True
# Reading the big chunk # Reading the big chunk
large_chunk, fs = torchaudio.load( large_chunk, fs = torchaudio.load(
str(audio_file), str(audio_file),
...@@ -171,10 +175,6 @@ class VAD(Pretrained): ...@@ -171,10 +175,6 @@ class VAD(Pretrained):
# Update counter to process the next big chunk # Update counter to process the next big chunk
begin_sample = begin_sample + long_chunk_len begin_sample = begin_sample + long_chunk_len
# Check if the current chunk is the last one
if begin_sample + long_chunk_len > audio_len:
last_chunk = True
# Converting the list to a tensor # Converting the list to a tensor
prob_vad = torch.cat(prob_chunks, dim=1) prob_vad = torch.cat(prob_chunks, dim=1)
last_elem = int(audio_len / (self.time_resolution * sample_rate)) last_elem = int(audio_len / (self.time_resolution * sample_rate))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment