Skip to content

Commit

Permalink
stream : fix handling of --step == --length (ggerganov#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Jan 18, 2023
1 parent 1ccb8a4 commit 9ba66c2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/stream/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ int main(int argc, char ** argv) {
return 1;
}

params.keep_ms = std::min(params.keep_ms, params.step_ms); // cannot be more than step_ms
params.keep_ms = std::min(params.keep_ms, params.step_ms);
params.length_ms = std::max(params.length_ms, params.step_ms);

const int n_samples_step = (params.step_ms *1e-3)*WHISPER_SAMPLE_RATE;
const int n_samples_len = (params.length_ms*1e-3)*WHISPER_SAMPLE_RATE;
Expand All @@ -432,7 +433,7 @@ int main(int argc, char ** argv) {

const bool use_vad = n_samples_step <= 0; // sliding window mode uses VAD

const int n_new_line = !use_vad ? params.length_ms / params.step_ms - 1 : 1; // number of steps to print new line
const int n_new_line = !use_vad ? std::max(1, params.length_ms / params.step_ms - 1) : 1; // number of steps to print new line

params.no_timestamps = !use_vad;
params.no_context |= use_vad;
Expand Down

0 comments on commit 9ba66c2

Please sign in to comment.