]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
node : support no timestamps (#2048)
authorPedro Probst <redacted>
Mon, 15 Apr 2024 17:03:34 +0000 (14:03 -0300)
committerGitHub <redacted>
Mon, 15 Apr 2024 17:03:34 +0000 (20:03 +0300)
* fix: node: do not compute timestamps if you do not need them

* feat: add no_timestamps parameter to node addon

examples/addon.node/addon.cpp

index ff46065645020feca62dd4c2753e799067303c50..8988f9edc1d0b92904a82abb2f449d19c508e0b3 100644 (file)
@@ -211,6 +211,8 @@ int run(whisper_params &params, std::vector<std::vector<std::string>> &result) {
 
             wparams.initial_prompt   = params.prompt.c_str();
 
+            wparams.no_timestamps    = params.no_timestamps;
+
             whisper_print_user_data user_data = { &params, &pcmf32s };
 
             // this callback is called on each new segment
@@ -298,11 +300,13 @@ Napi::Value whisper(const Napi::CallbackInfo& info) {
   std::string model = whisper_params.Get("model").As<Napi::String>();
   std::string input = whisper_params.Get("fname_inp").As<Napi::String>();
   bool use_gpu = whisper_params.Get("use_gpu").As<Napi::Boolean>();
+  bool no_timestamps = whisper_params.Get("no_timestamps").As<Napi::Boolean>();
 
   params.language = language;
   params.model = model;
   params.fname_inp.emplace_back(input);
   params.use_gpu = use_gpu;
+  params.no_timestamps = no_timestamps;
 
   Napi::Function callback = info[1].As<Napi::Function>();
   Worker* worker = new Worker(callback, params);