node : support no timestamps (#2048)

* fix: node: do not compute timestamps if you do not need them

* feat: add no_timestamps parameter to node addon
This commit is contained in:
Pedro Probst 2024-04-15 14:03:34 -03:00 committed by GitHub
parent c7f95b7ca2
commit 1b5439a6c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View 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.initial_prompt = params.prompt.c_str();
wparams.no_timestamps = params.no_timestamps;
whisper_print_user_data user_data = { &params, &pcmf32s }; whisper_print_user_data user_data = { &params, &pcmf32s };
// this callback is called on each new segment // 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 model = whisper_params.Get("model").As<Napi::String>();
std::string input = whisper_params.Get("fname_inp").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 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.language = language;
params.model = model; params.model = model;
params.fname_inp.emplace_back(input); params.fname_inp.emplace_back(input);
params.use_gpu = use_gpu; params.use_gpu = use_gpu;
params.no_timestamps = no_timestamps;
Napi::Function callback = info[1].As<Napi::Function>(); Napi::Function callback = info[1].As<Napi::Function>();
Worker* worker = new Worker(callback, params); Worker* worker = new Worker(callback, params);