Skip to content

Commit 950d7c5

Browse files
committed
vad : return early if no vad segments are detected
This commit adds a check to `whisper_full_with_state` and if no VAD segments are detected, the function will return early. The motivation for this is that if no VAD segments are detected, the function will not have any samples to process which can happen if an audio sample does not contain any speech. I did not test this previously and only discovered this when updating the stream example.
1 parent fc2b3f7 commit 950d7c5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/whisper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6746,6 +6746,9 @@ int whisper_full_with_state(
67466746
WHISPER_LOG_ERROR("%s: failed to compute VAD\n", __func__);
67476747
return -1;
67486748
}
6749+
if (vad_n_samples == 0) {
6750+
return 0;
6751+
}
67496752
process_samples = vad_samples.data();
67506753
n_process_samples = vad_n_samples;
67516754
}

0 commit comments

Comments
 (0)