Spaces:
Running
Running
stream : fix handling of --step == --length (#416)
Browse files
examples/stream/stream.cpp
CHANGED
|
@@ -423,7 +423,8 @@ int main(int argc, char ** argv) {
|
|
| 423 |
return 1;
|
| 424 |
}
|
| 425 |
|
| 426 |
-
params.keep_ms
|
|
|
|
| 427 |
|
| 428 |
const int n_samples_step = (params.step_ms *1e-3)*WHISPER_SAMPLE_RATE;
|
| 429 |
const int n_samples_len = (params.length_ms*1e-3)*WHISPER_SAMPLE_RATE;
|
|
@@ -432,7 +433,7 @@ int main(int argc, char ** argv) {
|
|
| 432 |
|
| 433 |
const bool use_vad = n_samples_step <= 0; // sliding window mode uses VAD
|
| 434 |
|
| 435 |
-
const int n_new_line = !use_vad ? params.length_ms / params.step_ms - 1 : 1; // number of steps to print new line
|
| 436 |
|
| 437 |
params.no_timestamps = !use_vad;
|
| 438 |
params.no_context |= use_vad;
|
|
|
|
| 423 |
return 1;
|
| 424 |
}
|
| 425 |
|
| 426 |
+
params.keep_ms = std::min(params.keep_ms, params.step_ms);
|
| 427 |
+
params.length_ms = std::max(params.length_ms, params.step_ms);
|
| 428 |
|
| 429 |
const int n_samples_step = (params.step_ms *1e-3)*WHISPER_SAMPLE_RATE;
|
| 430 |
const int n_samples_len = (params.length_ms*1e-3)*WHISPER_SAMPLE_RATE;
|
|
|
|
| 433 |
|
| 434 |
const bool use_vad = n_samples_step <= 0; // sliding window mode uses VAD
|
| 435 |
|
| 436 |
+
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
|
| 437 |
|
| 438 |
params.no_timestamps = !use_vad;
|
| 439 |
params.no_context |= use_vad;
|