Liu Song’s Projects


~/Projects/whisper.cpp

git clone https://code.lsong.org/whisper.cpp

Commit

Commit
f2df9bd7689475e73da6480212c1a0e6aa348979
Author
Georgi Gerganov <[email protected]>
Date
2022-11-20 21:22:02 +0200 +0200
Diffstat
 examples/stream/stream.cpp | 6 +++++-

stream : add "max_tokens" cli arg

Controls the max tokens per segment for the stream example


diff --git a/examples/stream/stream.cpp b/examples/stream/stream.cpp
index 4ff93d397f1e5fd493ab39f212b1a9161faec7c1..6f3634b79244da783153617d737007583adbae49 100644
--- a/examples/stream/stream.cpp
+++ b/examples/stream/stream.cpp
@@ -40,6 +40,7 @@     int32_t n_threads  = std::min(4, (int32_t) std::thread::hardware_concurrency());
     int32_t step_ms    = 3000;
     int32_t length_ms  = 10000;
     int32_t capture_id = -1;
+    int32_t max_tokens = 32;
     int32_t audio_ctx  = 0;
 
     bool speed_up             = false;
@@ -70,6 +71,8 @@         } else if (arg == "--length") {
             params.length_ms = std::stoi(argv[++i]);
         } else if (arg == "-c" || arg == "--capture") {
             params.capture_id = std::stoi(argv[++i]);
+        } else if (arg == "-mt" || arg == "--max_tokens") {
+            params.max_tokens = std::stoi(argv[++i]);
         } else if (arg == "-ac" || arg == "--audio_ctx") {
             params.audio_ctx = std::stoi(argv[++i]);
         } else if (arg == "-su" || arg == "--speed-up") {
@@ -119,6 +122,7 @@     fprintf(stderr, "  -t N,     --threads N      number of threads to use during computation (default: %d)\n", params.n_threads);
     fprintf(stderr, "            --step N         audio step size in milliseconds (default: %d)\n", params.step_ms);
     fprintf(stderr, "            --length N       audio length in milliseconds (default: %d)\n", params.length_ms);
     fprintf(stderr, "  -c ID,    --capture ID     capture device ID (default: -1)\n");
+    fprintf(stderr, "  -mt N,    --max_tokens N   maximum number of tokens per audio chunk (default: %d)\n", params.max_tokens);
     fprintf(stderr, "  -ac N,    --audio_ctx N    audio context size (default: %d, 0 - all)\n", params.audio_ctx);
     fprintf(stderr, "  -su,      --speed-up       speed up audio by factor of 2 (faster processing, reduced accuracy, default: %s)\n", params.speed_up ? "true" : "false");
     fprintf(stderr, "  -v,       --verbose        verbose output\n");
@@ -334,7 +338,7 @@             wparams.translate            = params.translate;
             wparams.no_context           = params.no_context;
             wparams.single_segment       = true;
 //
-    bool no_context           = true;
+            params.model = argv[++i];
             wparams.language             = params.language.c_str();
             wparams.n_threads            = params.n_threads;