From: Georgi Gerganov Date: Wed, 18 Jan 2023 19:22:52 +0000 (+0200) Subject: stream : fix handling of --step == --length (#416) X-Git-Tag: upstream/1.7.4~1608 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=9ba66c2fad13524091cc2d455fcd8329cfcf88db;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp stream : fix handling of --step == --length (#416) --- diff --git a/examples/stream/stream.cpp b/examples/stream/stream.cpp index fb0cb3dd..b2a1824c 100644 --- a/examples/stream/stream.cpp +++ b/examples/stream/stream.cpp @@ -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; @@ -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;