From: Georgi Gerganov Date: Sun, 20 Nov 2022 18:45:10 +0000 (+0200) Subject: stream : add "single_segment" option X-Git-Tag: upstream/1.7.4~1827 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=d351771a4b2eb6b35ff296538bf48a681382b8da;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp stream : add "single_segment" option Force the entire audio chunk to be transcribed into a single segment --- diff --git a/examples/stream/stream.cpp b/examples/stream/stream.cpp index 3c2f8612..d2db0b89 100644 --- a/examples/stream/stream.cpp +++ b/examples/stream/stream.cpp @@ -328,6 +328,7 @@ int main(int argc, char ** argv) { wparams.print_timestamps = !params.no_timestamps; wparams.translate = params.translate; wparams.no_context = params.no_context; + wparams.single_segment = true; wparams.language = params.language.c_str(); wparams.n_threads = params.n_threads; diff --git a/whisper.cpp b/whisper.cpp index 7c4a1d4c..95579ec3 100644 --- a/whisper.cpp +++ b/whisper.cpp @@ -2392,6 +2392,7 @@ struct whisper_full_params whisper_full_default_params(enum whisper_sampling_str /*.translate =*/ false, /*.no_context =*/ false, + /*.single_segment =*/ false, /*.print_special_tokens =*/ false, /*.print_progress =*/ true, /*.print_realtime =*/ false, @@ -2432,6 +2433,7 @@ struct whisper_full_params whisper_full_default_params(enum whisper_sampling_str /*.translate =*/ false, /*.no_context =*/ false, + /*.single_segment =*/ false, /*.print_special_tokens =*/ false, /*.print_progress =*/ true, /*.print_realtime =*/ false, @@ -2693,10 +2695,10 @@ int whisper_full( } } - // TODO: TMP TO MAKE STREAM WORK ON RPI4 === - result_len = i + 1; - seek_delta = 100*WHISPER_CHUNK_SIZE; - // ========================================= + if (params.single_segment) { + result_len = i + 1; + seek_delta = 100*WHISPER_CHUNK_SIZE; + } break; } diff --git a/whisper.h b/whisper.h index 769ae643..ec4b1fb6 100644 --- a/whisper.h +++ b/whisper.h @@ -194,6 +194,7 @@ extern "C" { bool translate; bool no_context; + bool single_segment; // force single segment output (useful for streaming) bool print_special_tokens; bool print_progress; bool print_realtime;