Add blank penalty for various language bindings. (#1234)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -113,3 +113,4 @@ sherpa-onnx-telespeech-ctc-*
|
||||
lib*.a
|
||||
sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17
|
||||
*.bak
|
||||
vits-melo-tts-zh_en
|
||||
|
||||
19
CHANGELOG.md
19
CHANGELOG.md
@@ -1,3 +1,22 @@
|
||||
## 1.10.21
|
||||
|
||||
* Fix ffmpeg c api example (#1185)
|
||||
* Fix splitting sentences for MeloTTS (#1186)
|
||||
* Non-streaming WebSocket client for Java. (#1190)
|
||||
* Fix copying asset files for flutter examples. (#1191)
|
||||
* Add Chinese+English tts example for flutter (#1192)
|
||||
* Add speaker identification and verification exmaple for Dart API (#1194)
|
||||
* Fix reading non-standard wav files. (#1199)
|
||||
* Add ReazonSpeech Japanese pre-trained model (#1203)
|
||||
* Describe how to add new words for MeloTTS models (#1209)
|
||||
* Remove libonnxruntime_providers_cuda.so as a dependency. (#1210)
|
||||
* Fix setting SenseVoice language. (#1214)
|
||||
* Support passing TTS callback in Swift API (#1218)
|
||||
* Add MeloTTS example for ios (#1223)
|
||||
* Add online punctuation and casing prediction model for English language (#1224)
|
||||
* Fix python two pass ASR examples (#1230)
|
||||
* Add blank penalty for various language bindings
|
||||
|
||||
## 1.10.20
|
||||
|
||||
* Add Dart API for audio tagging
|
||||
|
||||
@@ -11,7 +11,7 @@ project(sherpa-onnx)
|
||||
# ./nodejs-addon-examples
|
||||
# ./dart-api-examples/
|
||||
# ./CHANGELOG.md
|
||||
set(SHERPA_ONNX_VERSION "1.10.20")
|
||||
set(SHERPA_ONNX_VERSION "1.10.21")
|
||||
|
||||
# Disable warning about
|
||||
#
|
||||
|
||||
@@ -126,7 +126,7 @@ echo "Generate xcframework"
|
||||
|
||||
mkdir -p "build/simulator/lib"
|
||||
for f in libkaldi-native-fbank-core.a libsherpa-onnx-c-api.a libsherpa-onnx-core.a \
|
||||
libsherpa-onnx-fst.a libsherpa-onnx-kaldifst-core.a libkaldi-decoder-core.a libssentencepiece_core.a; do
|
||||
libsherpa-onnx-fst.a libsherpa-onnx-fstfar.a libsherpa-onnx-kaldifst-core.a libkaldi-decoder-core.a libssentencepiece_core.a; do
|
||||
lipo -create build/simulator_arm64/lib/${f} \
|
||||
build/simulator_x86_64/lib/${f} \
|
||||
-output build/simulator/lib/${f}
|
||||
@@ -139,6 +139,7 @@ libtool -static -o build/simulator/sherpa-onnx.a \
|
||||
build/simulator/lib/libsherpa-onnx-c-api.a \
|
||||
build/simulator/lib/libsherpa-onnx-core.a \
|
||||
build/simulator/lib/libsherpa-onnx-fst.a \
|
||||
build/simulator/lib/libsherpa-onnx-fstfar.a \
|
||||
build/simulator/lib/libsherpa-onnx-kaldifst-core.a \
|
||||
build/simulator/lib/libkaldi-decoder-core.a \
|
||||
build/simulator/lib/libssentencepiece_core.a
|
||||
@@ -148,6 +149,7 @@ libtool -static -o build/os64/sherpa-onnx.a \
|
||||
build/os64/lib/libsherpa-onnx-c-api.a \
|
||||
build/os64/lib/libsherpa-onnx-core.a \
|
||||
build/os64/lib/libsherpa-onnx-fst.a \
|
||||
build/os64/lib/libsherpa-onnx-fstfar.a \
|
||||
build/os64/lib/libsherpa-onnx-kaldifst-core.a \
|
||||
build/os64/lib/libkaldi-decoder-core.a \
|
||||
build/os64/lib/libssentencepiece_core.a
|
||||
|
||||
@@ -9,7 +9,7 @@ environment:
|
||||
sdk: ^3.4.0
|
||||
|
||||
dependencies:
|
||||
sherpa_onnx: ^1.10.20
|
||||
sherpa_onnx: ^1.10.21
|
||||
path: ^1.9.0
|
||||
args: ^2.5.0
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ environment:
|
||||
sdk: ^3.4.0
|
||||
|
||||
dependencies:
|
||||
sherpa_onnx: ^1.10.20
|
||||
sherpa_onnx: ^1.10.21
|
||||
path: ^1.9.0
|
||||
args: ^2.5.0
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ environment:
|
||||
sdk: ^3.4.0
|
||||
|
||||
dependencies:
|
||||
sherpa_onnx: ^1.10.20
|
||||
sherpa_onnx: ^1.10.21
|
||||
# sherpa_onnx:
|
||||
# path: ../../flutter/sherpa_onnx
|
||||
path: ^1.9.0
|
||||
|
||||
@@ -10,7 +10,7 @@ environment:
|
||||
|
||||
# Add regular dependencies here.
|
||||
dependencies:
|
||||
sherpa_onnx: ^1.10.20
|
||||
sherpa_onnx: ^1.10.21
|
||||
path: ^1.9.0
|
||||
args: ^2.5.0
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ environment:
|
||||
sdk: ^3.4.0
|
||||
|
||||
dependencies:
|
||||
sherpa_onnx: ^1.10.20
|
||||
sherpa_onnx: ^1.10.21
|
||||
path: ^1.9.0
|
||||
args: ^2.5.0
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ environment:
|
||||
|
||||
# Add regular dependencies here.
|
||||
dependencies:
|
||||
sherpa_onnx: ^1.10.20
|
||||
sherpa_onnx: ^1.10.21
|
||||
path: ^1.9.0
|
||||
args: ^2.5.0
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ environment:
|
||||
|
||||
# Add regular dependencies here.
|
||||
dependencies:
|
||||
sherpa_onnx: ^1.10.20
|
||||
sherpa_onnx: ^1.10.21
|
||||
path: ^1.9.0
|
||||
args: ^2.5.0
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ environment:
|
||||
sdk: ^3.4.0
|
||||
|
||||
dependencies:
|
||||
sherpa_onnx: ^1.10.20
|
||||
sherpa_onnx: ^1.10.21
|
||||
path: ^1.9.0
|
||||
args: ^2.5.0
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ environment:
|
||||
sdk: ^3.4.0
|
||||
|
||||
dependencies:
|
||||
sherpa_onnx: ^1.10.20
|
||||
sherpa_onnx: ^1.10.21
|
||||
path: ^1.9.0
|
||||
args: ^2.5.0
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ description: >
|
||||
|
||||
publish_to: 'none'
|
||||
|
||||
version: 1.10.20
|
||||
version: 1.10.21
|
||||
|
||||
topics:
|
||||
- speech-recognition
|
||||
@@ -30,7 +30,7 @@ dependencies:
|
||||
record: ^5.1.0
|
||||
url_launcher: ^6.2.6
|
||||
|
||||
sherpa_onnx: ^1.10.20
|
||||
sherpa_onnx: ^1.10.21
|
||||
# sherpa_onnx:
|
||||
# path: ../../flutter/sherpa_onnx
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ description: >
|
||||
|
||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
|
||||
version: 1.10.20
|
||||
version: 1.10.21
|
||||
|
||||
environment:
|
||||
sdk: '>=3.4.0 <4.0.0'
|
||||
@@ -17,7 +17,7 @@ dependencies:
|
||||
cupertino_icons: ^1.0.6
|
||||
path_provider: ^2.1.3
|
||||
path: ^1.9.0
|
||||
sherpa_onnx: ^1.10.20
|
||||
sherpa_onnx: ^1.10.21
|
||||
url_launcher: ^6.2.6
|
||||
audioplayers: ^5.0.0
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -114,11 +114,12 @@ class OnlineRecognizerConfig {
|
||||
this.ctcFstDecoderConfig = const OnlineCtcFstDecoderConfig(),
|
||||
this.ruleFsts = '',
|
||||
this.ruleFars = '',
|
||||
this.blankPenalty = 0.0,
|
||||
});
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OnlineRecognizerConfig(feat: $feat, model: $model, decodingMethod: $decodingMethod, maxActivePaths: $maxActivePaths, enableEndpoint: $enableEndpoint, rule1MinTrailingSilence: $rule1MinTrailingSilence, rule2MinTrailingSilence: $rule2MinTrailingSilence, rule3MinUtteranceLength: $rule3MinUtteranceLength, hotwordsFile: $hotwordsFile, hotwordsScore: $hotwordsScore, ctcFstDecoderConfig: $ctcFstDecoderConfig, ruleFsts: $ruleFsts, ruleFars: $ruleFars)';
|
||||
return 'OnlineRecognizerConfig(feat: $feat, model: $model, decodingMethod: $decodingMethod, maxActivePaths: $maxActivePaths, enableEndpoint: $enableEndpoint, rule1MinTrailingSilence: $rule1MinTrailingSilence, rule2MinTrailingSilence: $rule2MinTrailingSilence, rule3MinUtteranceLength: $rule3MinUtteranceLength, hotwordsFile: $hotwordsFile, hotwordsScore: $hotwordsScore, ctcFstDecoderConfig: $ctcFstDecoderConfig, ruleFsts: $ruleFsts, ruleFars: $ruleFars, blankPenalty: $blankPenalty)';
|
||||
}
|
||||
|
||||
final FeatureConfig feat;
|
||||
@@ -142,6 +143,8 @@ class OnlineRecognizerConfig {
|
||||
final OnlineCtcFstDecoderConfig ctcFstDecoderConfig;
|
||||
final String ruleFsts;
|
||||
final String ruleFars;
|
||||
|
||||
final double blankPenalty;
|
||||
}
|
||||
|
||||
class OnlineRecognizerResult {
|
||||
@@ -209,6 +212,8 @@ class OnlineRecognizer {
|
||||
c.ref.ruleFsts = config.ruleFsts.toNativeUtf8();
|
||||
c.ref.ruleFars = config.ruleFars.toNativeUtf8();
|
||||
|
||||
c.ref.blankPenalty = config.blankPenalty;
|
||||
|
||||
final ptr = SherpaOnnxBindings.createOnlineRecognizer?.call(c) ?? nullptr;
|
||||
|
||||
calloc.free(c.ref.ruleFars);
|
||||
|
||||
@@ -194,6 +194,9 @@ final class SherpaOnnxOfflineRecognizerConfig extends Struct {
|
||||
|
||||
external Pointer<Utf8> ruleFsts;
|
||||
external Pointer<Utf8> ruleFars;
|
||||
|
||||
@Float()
|
||||
external double blankPenalty;
|
||||
}
|
||||
|
||||
final class SherpaOnnxOnlineTransducerModelConfig extends Struct {
|
||||
@@ -269,6 +272,9 @@ final class SherpaOnnxOnlineRecognizerConfig extends Struct {
|
||||
|
||||
external Pointer<Utf8> ruleFsts;
|
||||
external Pointer<Utf8> ruleFars;
|
||||
|
||||
@Float()
|
||||
external double blankPenalty;
|
||||
}
|
||||
|
||||
final class SherpaOnnxSileroVadModelConfig extends Struct {
|
||||
|
||||
@@ -17,7 +17,7 @@ topics:
|
||||
- voice-activity-detection
|
||||
|
||||
# remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec
|
||||
version: 1.10.20
|
||||
version: 1.10.21
|
||||
|
||||
homepage: https://github.com/k2-fsa/sherpa-onnx
|
||||
|
||||
@@ -30,23 +30,23 @@ dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
sherpa_onnx_android: ^1.10.20
|
||||
sherpa_onnx_android: ^1.10.21
|
||||
# sherpa_onnx_android:
|
||||
# path: ../sherpa_onnx_android
|
||||
|
||||
sherpa_onnx_macos: ^1.10.20
|
||||
sherpa_onnx_macos: ^1.10.21
|
||||
# sherpa_onnx_macos:
|
||||
# path: ../sherpa_onnx_macos
|
||||
|
||||
sherpa_onnx_linux: ^1.10.20
|
||||
sherpa_onnx_linux: ^1.10.21
|
||||
# sherpa_onnx_linux:
|
||||
# path: ../sherpa_onnx_linux
|
||||
#
|
||||
sherpa_onnx_windows: ^1.10.20
|
||||
sherpa_onnx_windows: ^1.10.21
|
||||
# sherpa_onnx_windows:
|
||||
# path: ../sherpa_onnx_windows
|
||||
|
||||
sherpa_onnx_ios: ^1.10.20
|
||||
sherpa_onnx_ios: ^1.10.21
|
||||
# sherpa_onnx_ios:
|
||||
# path: ../sherpa_onnx_ios
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# https://groups.google.com/g/dart-ffi/c/nUATMBy7r0c
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'sherpa_onnx_ios'
|
||||
s.version = '1.10.20'
|
||||
s.version = '1.10.21'
|
||||
s.summary = 'A new Flutter FFI plugin project.'
|
||||
s.description = <<-DESC
|
||||
A new Flutter FFI plugin project.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'sherpa_onnx_macos'
|
||||
s.version = '1.10.20'
|
||||
s.version = '1.10.21'
|
||||
s.summary = 'sherpa-onnx Flutter FFI plugin project.'
|
||||
s.description = <<-DESC
|
||||
sherpa-onnx Flutter FFI plugin project.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"sherpa-onnx-node": "^1.10.20"
|
||||
"sherpa-onnx-node": "^1.10.21"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace SherpaOnnx
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct OfflineRecognizerConfig
|
||||
{
|
||||
@@ -20,6 +19,7 @@ namespace SherpaOnnx
|
||||
HotwordsScore = 1.5F;
|
||||
RuleFsts = "";
|
||||
RuleFars = "";
|
||||
BlankPenalty = 0.0F;
|
||||
}
|
||||
public FeatureConfig FeatConfig;
|
||||
public OfflineModelConfig ModelConfig;
|
||||
@@ -40,7 +40,7 @@ namespace SherpaOnnx
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string RuleFars;
|
||||
|
||||
public float BlankPenalty;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace SherpaOnnx
|
||||
CtcFstDecoderConfig = new OnlineCtcFstDecoderConfig();
|
||||
RuleFsts = "";
|
||||
RuleFars = "";
|
||||
BlankPenalty = 0.0F;
|
||||
}
|
||||
public FeatureConfig FeatConfig;
|
||||
public OnlineModelConfig ModelConfig;
|
||||
@@ -69,6 +70,7 @@ namespace SherpaOnnx
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string RuleFars;
|
||||
}
|
||||
|
||||
}
|
||||
public float BlankPenalty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,6 +201,7 @@ CreateOfflineRecognizerWrapper(const Napi::CallbackInfo &info) {
|
||||
SHERPA_ONNX_ASSIGN_ATTR_FLOAT(hotwords_score, hotwordsScore);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fsts, ruleFsts);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fars, ruleFars);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_FLOAT(blank_penalty, blankPenalty);
|
||||
|
||||
SherpaOnnxOfflineRecognizer *recognizer =
|
||||
SherpaOnnxCreateOfflineRecognizer(&c);
|
||||
|
||||
@@ -191,6 +191,7 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper(
|
||||
SHERPA_ONNX_ASSIGN_ATTR_FLOAT(hotwords_score, hotwordsScore);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fsts, ruleFsts);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fars, ruleFars);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_FLOAT(blank_penalty, blankPenalty);
|
||||
|
||||
c.ctc_fst_decoder_config = GetCtcFstDecoderConfig(o);
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ SherpaOnnxOnlineRecognizer *SherpaOnnxCreateOnlineRecognizer(
|
||||
recognizer_config.hotwords_score =
|
||||
SHERPA_ONNX_OR(config->hotwords_score, 1.5);
|
||||
|
||||
recognizer_config.blank_penalty = SHERPA_ONNX_OR(config->blank_penalty, 0.0);
|
||||
recognizer_config.blank_penalty = config->blank_penalty;
|
||||
|
||||
recognizer_config.ctc_fst_decoder_config.graph =
|
||||
SHERPA_ONNX_OR(config->ctc_fst_decoder_config.graph, "");
|
||||
@@ -429,6 +429,8 @@ sherpa_onnx::OfflineRecognizerConfig convertConfig(
|
||||
recognizer_config.hotwords_score =
|
||||
SHERPA_ONNX_OR(config->hotwords_score, 1.5);
|
||||
|
||||
recognizer_config.blank_penalty = config->blank_penalty;
|
||||
|
||||
recognizer_config.rule_fsts = SHERPA_ONNX_OR(config->rule_fsts, "");
|
||||
recognizer_config.rule_fars = SHERPA_ONNX_OR(config->rule_fars, "");
|
||||
|
||||
|
||||
@@ -142,11 +142,11 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineRecognizerConfig {
|
||||
|
||||
/// Bonus score for each token in hotwords.
|
||||
float hotwords_score;
|
||||
float blank_penalty;
|
||||
|
||||
SherpaOnnxOnlineCtcFstDecoderConfig ctc_fst_decoder_config;
|
||||
const char *rule_fsts;
|
||||
const char *rule_fars;
|
||||
float blank_penalty;
|
||||
} SherpaOnnxOnlineRecognizerConfig;
|
||||
|
||||
SHERPA_ONNX_API typedef struct SherpaOnnxOnlineRecognizerResult {
|
||||
@@ -430,6 +430,7 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineRecognizerConfig {
|
||||
float hotwords_score;
|
||||
const char *rule_fsts;
|
||||
const char *rule_fars;
|
||||
float blank_penalty;
|
||||
} SherpaOnnxOfflineRecognizerConfig;
|
||||
|
||||
SHERPA_ONNX_API typedef struct SherpaOnnxOfflineRecognizer
|
||||
|
||||
@@ -11,6 +11,7 @@ public class OfflineRecognizerConfig {
|
||||
private final float hotwordsScore;
|
||||
private final String ruleFsts;
|
||||
private final String ruleFars;
|
||||
private final float blankPenalty;
|
||||
|
||||
private OfflineRecognizerConfig(Builder builder) {
|
||||
this.featConfig = builder.featConfig;
|
||||
@@ -21,6 +22,7 @@ public class OfflineRecognizerConfig {
|
||||
this.hotwordsScore = builder.hotwordsScore;
|
||||
this.ruleFsts = builder.ruleFsts;
|
||||
this.ruleFars = builder.ruleFars;
|
||||
this.blankPenalty = builder.blankPenalty;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
@@ -40,6 +42,7 @@ public class OfflineRecognizerConfig {
|
||||
private float hotwordsScore = 1.5f;
|
||||
private String ruleFsts = "";
|
||||
private String ruleFars = "";
|
||||
private float blankPenalty = 0.0f;
|
||||
|
||||
public OfflineRecognizerConfig build() {
|
||||
return new OfflineRecognizerConfig(this);
|
||||
@@ -84,5 +87,10 @@ public class OfflineRecognizerConfig {
|
||||
this.ruleFars = ruleFars;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setBlankPenalty(float blankPenalty) {
|
||||
this.blankPenalty = blankPenalty;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public class OnlineRecognizerConfig {
|
||||
private final float hotwordsScore;
|
||||
private final String ruleFsts;
|
||||
private final String ruleFars;
|
||||
private final float blankPenalty;
|
||||
|
||||
private OnlineRecognizerConfig(Builder builder) {
|
||||
this.featConfig = builder.featConfig;
|
||||
@@ -31,6 +32,7 @@ public class OnlineRecognizerConfig {
|
||||
this.hotwordsScore = builder.hotwordsScore;
|
||||
this.ruleFsts = builder.ruleFsts;
|
||||
this.ruleFars = builder.ruleFars;
|
||||
this.blankPenalty = builder.blankPenalty;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
@@ -54,6 +56,7 @@ public class OnlineRecognizerConfig {
|
||||
private float hotwordsScore = 1.5f;
|
||||
private String ruleFsts = "";
|
||||
private String ruleFars = "";
|
||||
private float blankPenalty = 0.0f;
|
||||
|
||||
public OnlineRecognizerConfig build() {
|
||||
return new OnlineRecognizerConfig(this);
|
||||
@@ -118,5 +121,10 @@ public class OnlineRecognizerConfig {
|
||||
this.ruleFars = ruleFars;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setBlankPenalty(float blankPenalty) {
|
||||
this.blankPenalty = blankPenalty;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ static OfflineRecognizerConfig GetOfflineConfig(JNIEnv *env, jobject config) {
|
||||
ans.rule_fars = p;
|
||||
env->ReleaseStringUTFChars(s, p);
|
||||
|
||||
fid = env->GetFieldID(cls, "blankPenalty", "F");
|
||||
ans.blank_penalty = env->GetFloatField(config, fid);
|
||||
|
||||
//---------- feat config ----------
|
||||
fid = env->GetFieldID(cls, "featConfig",
|
||||
"Lcom/k2fsa/sherpa/onnx/FeatureConfig;");
|
||||
|
||||
@@ -49,6 +49,9 @@ static OnlineRecognizerConfig GetConfig(JNIEnv *env, jobject config) {
|
||||
ans.rule_fars = p;
|
||||
env->ReleaseStringUTFChars(s, p);
|
||||
|
||||
fid = env->GetFieldID(cls, "blankPenalty", "F");
|
||||
ans.blank_penalty = env->GetFloatField(config, fid);
|
||||
|
||||
//---------- feat config ----------
|
||||
fid = env->GetFieldID(cls, "featConfig",
|
||||
"Lcom/k2fsa/sherpa/onnx/FeatureConfig;");
|
||||
|
||||
@@ -62,6 +62,7 @@ data class OfflineRecognizerConfig(
|
||||
var hotwordsScore: Float = 1.5f,
|
||||
var ruleFsts: String = "",
|
||||
var ruleFars: String = "",
|
||||
var blankPenalty: Float = 0.0f,
|
||||
)
|
||||
|
||||
class OfflineRecognizer(
|
||||
|
||||
@@ -71,6 +71,7 @@ data class OnlineRecognizerConfig(
|
||||
var hotwordsScore: Float = 1.5f,
|
||||
var ruleFsts: String = "",
|
||||
var ruleFars: String = "",
|
||||
var blankPenalty: Float = 0.0f,
|
||||
)
|
||||
|
||||
data class OnlineRecognizerResult(
|
||||
|
||||
@@ -137,7 +137,8 @@ func sherpaOnnxOnlineRecognizerConfig(
|
||||
hotwordsScore: Float = 1.5,
|
||||
ctcFstDecoderConfig: SherpaOnnxOnlineCtcFstDecoderConfig = sherpaOnnxOnlineCtcFstDecoderConfig(),
|
||||
ruleFsts: String = "",
|
||||
ruleFars: String = ""
|
||||
ruleFars: String = "",
|
||||
blankPenalty: Float = 0.0
|
||||
) -> SherpaOnnxOnlineRecognizerConfig {
|
||||
return SherpaOnnxOnlineRecognizerConfig(
|
||||
feat_config: featConfig,
|
||||
@@ -152,7 +153,8 @@ func sherpaOnnxOnlineRecognizerConfig(
|
||||
hotwords_score: hotwordsScore,
|
||||
ctc_fst_decoder_config: ctcFstDecoderConfig,
|
||||
rule_fsts: toCPointer(ruleFsts),
|
||||
rule_fars: toCPointer(ruleFars)
|
||||
rule_fars: toCPointer(ruleFars),
|
||||
blank_penalty: blankPenalty
|
||||
)
|
||||
}
|
||||
|
||||
@@ -420,7 +422,8 @@ func sherpaOnnxOfflineRecognizerConfig(
|
||||
hotwordsFile: String = "",
|
||||
hotwordsScore: Float = 1.5,
|
||||
ruleFsts: String = "",
|
||||
ruleFars: String = ""
|
||||
ruleFars: String = "",
|
||||
blankPenalty: Float = 0.0
|
||||
) -> SherpaOnnxOfflineRecognizerConfig {
|
||||
return SherpaOnnxOfflineRecognizerConfig(
|
||||
feat_config: featConfig,
|
||||
@@ -431,7 +434,8 @@ func sherpaOnnxOfflineRecognizerConfig(
|
||||
hotwords_file: toCPointer(hotwordsFile),
|
||||
hotwords_score: hotwordsScore,
|
||||
rule_fsts: toCPointer(ruleFsts),
|
||||
rule_fars: toCPointer(ruleFars)
|
||||
rule_fars: toCPointer(ruleFars),
|
||||
blank_penalty: blankPenalty
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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