Add blank penalty for various language bindings. (#1234)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ static_assert(sizeof(SherpaOnnxOnlineCtcFstDecoderConfig) == 2 * 4, "");
|
||||
static_assert(sizeof(SherpaOnnxOnlineRecognizerConfig) ==
|
||||
sizeof(SherpaOnnxFeatureConfig) +
|
||||
sizeof(SherpaOnnxOnlineModelConfig) + 8 * 4 +
|
||||
sizeof(SherpaOnnxOnlineCtcFstDecoderConfig) + 2 * 4,
|
||||
sizeof(SherpaOnnxOnlineCtcFstDecoderConfig) + 3 * 4,
|
||||
"");
|
||||
|
||||
void MyPrint(SherpaOnnxOnlineRecognizerConfig *config) {
|
||||
@@ -73,6 +73,7 @@ void MyPrint(SherpaOnnxOnlineRecognizerConfig *config) {
|
||||
fprintf(stdout, "hotwords_score: %.2f\n", config->hotwords_score);
|
||||
fprintf(stdout, "rule_fsts: %s\n", config->rule_fsts);
|
||||
fprintf(stdout, "rule_fars: %s\n", config->rule_fars);
|
||||
fprintf(stdout, "blank_penalty: %f\n", config->blank_penalty);
|
||||
|
||||
fprintf(stdout, "----------ctc fst decoder config----------\n");
|
||||
fprintf(stdout, "graph: %s\n", config->ctc_fst_decoder_config.graph);
|
||||
|
||||
@@ -31,7 +31,7 @@ static_assert(sizeof(SherpaOnnxFeatureConfig) == 2 * 4, "");
|
||||
static_assert(sizeof(SherpaOnnxOfflineRecognizerConfig) ==
|
||||
sizeof(SherpaOnnxFeatureConfig) +
|
||||
sizeof(SherpaOnnxOfflineLMConfig) +
|
||||
sizeof(SherpaOnnxOfflineModelConfig) + 6 * 4,
|
||||
sizeof(SherpaOnnxOfflineModelConfig) + 7 * 4,
|
||||
"");
|
||||
|
||||
void PrintOfflineTtsConfig(SherpaOnnxOfflineTtsConfig *tts_config) {
|
||||
@@ -113,6 +113,7 @@ void PrintOfflineRecognizerConfig(SherpaOnnxOfflineRecognizerConfig *config) {
|
||||
fprintf(stdout, "hotwords_score: %.2f\n", config->hotwords_score);
|
||||
fprintf(stdout, "rule_fsts: %s\n", config->rule_fsts);
|
||||
fprintf(stdout, "rule_fars: %s\n", config->rule_fars);
|
||||
fprintf(stdout, "blank_penalty: %f\n", config->blank_penalty);
|
||||
}
|
||||
|
||||
void CopyHeap(const char *src, int32_t num_bytes, char *dst) {
|
||||
|
||||
Reference in New Issue
Block a user