Skip to content

Commit e853620

Browse files
buxukulinxiaodong
and
linxiaodong
authored
addon.node : support max_context api for addon.node (#3025)
* feat: support max content * feat: show api in test file --------- Co-authored-by: linxiaodong <[email protected]>
1 parent 549db93 commit e853620

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

examples/addon.node/__test__/whisper.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ const whisperParamsMock = {
1919
no_timestamps: false,
2020
audio_ctx: 0,
2121
max_len: 0,
22+
prompt: "",
23+
print_progress: false,
24+
progress_callback: (progress) => {
25+
console.log(`Progress: ${progress}`);
26+
},
27+
max_context: -1
2228
};
2329

2430
describe("Run whisper.node", () => {

examples/addon.node/addon.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,12 @@ Napi::Value whisper(const Napi::CallbackInfo& info) {
368368
bool comma_in_time = whisper_params.Get("comma_in_time").As<Napi::Boolean>();
369369
int32_t max_len = whisper_params.Get("max_len").As<Napi::Number>();
370370

371+
// Add support for max_context
372+
int32_t max_context = -1;
373+
if (whisper_params.Has("max_context") && whisper_params.Get("max_context").IsNumber()) {
374+
max_context = whisper_params.Get("max_context").As<Napi::Number>();
375+
}
376+
371377
// support prompt
372378
std::string prompt = "";
373379
if (whisper_params.Has("prompt") && whisper_params.Get("prompt").IsString()) {
@@ -407,6 +413,7 @@ Napi::Value whisper(const Napi::CallbackInfo& info) {
407413
params.pcmf32 = pcmf32_vec;
408414
params.comma_in_time = comma_in_time;
409415
params.max_len = max_len;
416+
params.max_context = max_context;
410417
params.print_progress = print_progress;
411418
params.prompt = prompt;
412419

0 commit comments

Comments
 (0)