danbev commited on
Commit
a28f11e
·
unverified ·
1 Parent(s): 821d05f

vad : return early if no vad segments are detected (#3158)

Browse files

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.

Files changed (1) hide show
  1. src/whisper.cpp +3 -0
src/whisper.cpp CHANGED
@@ -6746,6 +6746,9 @@ int whisper_full_with_state(
6746
  WHISPER_LOG_ERROR("%s: failed to compute VAD\n", __func__);
6747
  return -1;
6748
  }
 
 
 
6749
  process_samples = vad_samples.data();
6750
  n_process_samples = vad_n_samples;
6751
  }
 
6746
  WHISPER_LOG_ERROR("%s: failed to compute VAD\n", __func__);
6747
  return -1;
6748
  }
6749
+ if (vad_n_samples == 0) {
6750
+ return 0;
6751
+ }
6752
  process_samples = vad_samples.data();
6753
  n_process_samples = vad_n_samples;
6754
  }