]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
stream : add "single_segment" option
authorGeorgi Gerganov <redacted>
Sun, 20 Nov 2022 18:45:10 +0000 (20:45 +0200)
committerGeorgi Gerganov <redacted>
Sun, 20 Nov 2022 19:22:41 +0000 (21:22 +0200)
Force the entire audio chunk to be transcribed into a single segment

examples/stream/stream.cpp
whisper.cpp
whisper.h

index 3c2f86126d992a8a1a550a5b5d6d59ad6e2caa8f..d2db0b899342ba4dcc5c2ea306e0b249df759dbb 100644 (file)
@@ -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;
 
index 7c4a1d4c4b65dafb14728940faad9d7739c414a7..95579ec38fe81aa91ea9a9a0b6bfe0f2d3ce01e5 100644 (file)
@@ -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;
                 }
index 769ae643983f8bd8e86aad5021af8c26896206fc..ec4b1fb6c53ec60ee6097e5ef21ac7d3c27a6117 100644 (file)
--- 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;