Add blank penalty for various language bindings. (#1234)

This commit is contained in:
Fangjun Kuang
2024-08-08 10:43:31 +08:00
committed by GitHub
parent ba4cb6169f
commit 94e256244d
38 changed files with 123 additions and 42 deletions

View File

@@ -280,7 +280,7 @@ function initSherpaOnnxOnlineRecognizerConfig(config, Module) {
const ctcFstDecoder = initSherpaOnnxOnlineCtcFstDecoderConfig(
config.ctcFstDecoderConfig, Module)
const len = feat.len + model.len + 8 * 4 + ctcFstDecoder.len + 2 * 4;
const len = feat.len + model.len + 8 * 4 + ctcFstDecoder.len + 3 * 4;
const ptr = Module._malloc(len);
let offset = 0;
@@ -351,6 +351,9 @@ function initSherpaOnnxOnlineRecognizerConfig(config, Module) {
buffer + decodingMethodLen + hotwordsFileLen + ruleFstsFileLen, 'i8*');
offset += 4;
Module.setValue(ptr + offset, config.blankPenalty || 0, 'float');
offset += 4;
return {
buffer: buffer, ptr: ptr, len: len, feat: feat, model: model,
ctcFstDecoder: ctcFstDecoder
@@ -796,7 +799,7 @@ function initSherpaOnnxOfflineRecognizerConfig(config, Module) {
const model = initSherpaOnnxOfflineModelConfig(config.modelConfig, Module);
const lm = initSherpaOnnxOfflineLMConfig(config.lmConfig, Module);
const len = feat.len + model.len + lm.len + 6 * 4;
const len = feat.len + model.len + lm.len + 7 * 4;
const ptr = Module._malloc(len);
let offset = 0;
@@ -856,6 +859,9 @@ function initSherpaOnnxOfflineRecognizerConfig(config, Module) {
'i8*');
offset += 4;
Module.setValue(ptr + offset, config.blankPenalty || 0, 'float');
offset += 4;
return {
buffer: buffer, ptr: ptr, len: len, feat: feat, model: model, lm: lm
}