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

@@ -159,11 +159,12 @@ class OfflineRecognizerConfig {
this.hotwordsScore = 1.5,
this.ruleFsts = '',
this.ruleFars = '',
this.blankPenalty = 0.0,
});
@override
String toString() {
return 'OfflineRecognizerConfig(feat: $feat, model: $model, lm: $lm, decodingMethod: $decodingMethod, maxActivePaths: $maxActivePaths, hotwordsFile: $hotwordsFile, hotwordsScore: $hotwordsScore, ruleFsts: $ruleFsts, ruleFars: $ruleFars)';
return 'OfflineRecognizerConfig(feat: $feat, model: $model, lm: $lm, decodingMethod: $decodingMethod, maxActivePaths: $maxActivePaths, hotwordsFile: $hotwordsFile, hotwordsScore: $hotwordsScore, ruleFsts: $ruleFsts, ruleFars: $ruleFars, blankPenalty: $blankPenalty)';
}
final FeatureConfig feat;
@@ -179,6 +180,8 @@ class OfflineRecognizerConfig {
final String ruleFsts;
final String ruleFars;
final double blankPenalty;
}
class OfflineRecognizerResult {
@@ -268,6 +271,8 @@ class OfflineRecognizer {
c.ref.ruleFsts = config.ruleFsts.toNativeUtf8();
c.ref.ruleFars = config.ruleFars.toNativeUtf8();
c.ref.blankPenalty = config.blankPenalty;
final ptr = SherpaOnnxBindings.createOfflineRecognizer?.call(c) ?? nullptr;
calloc.free(c.ref.ruleFars);