Skip to content

Commit d1f114d

Browse files
authored
vad : return early if no vad segments are detected (#3158)
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 bae5d07 commit d1f114d

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)