feat: addition of blank_penalty config in online_recognizer (#1232)
This commit is contained in:
@@ -129,6 +129,7 @@ type OnlineRecognizerConfig struct {
|
||||
Rule3MinUtteranceLength float32
|
||||
HotwordsFile string
|
||||
HotwordsScore float32
|
||||
BlankPenalty float32
|
||||
CtcFstDecoderConfig OnlineCtcFstDecoderConfig
|
||||
RuleFsts string
|
||||
RuleFars string
|
||||
@@ -212,6 +213,7 @@ func NewOnlineRecognizer(config *OnlineRecognizerConfig) *OnlineRecognizer {
|
||||
defer C.free(unsafe.Pointer(c.hotwords_file))
|
||||
|
||||
c.hotwords_score = C.float(config.HotwordsScore)
|
||||
c.blank_penalty = C.float(config.BlankPenalty)
|
||||
|
||||
c.rule_fsts = C.CString(config.RuleFsts)
|
||||
defer C.free(unsafe.Pointer(c.rule_fsts))
|
||||
@@ -421,6 +423,7 @@ type OfflineRecognizerConfig struct {
|
||||
MaxActivePaths int
|
||||
HotwordsFile string
|
||||
HotwordsScore float32
|
||||
BlankPenalty float32
|
||||
RuleFsts string
|
||||
RuleFars string
|
||||
}
|
||||
@@ -530,6 +533,8 @@ func NewOfflineRecognizer(config *OfflineRecognizerConfig) *OfflineRecognizer {
|
||||
|
||||
c.hotwords_score = C.float(config.HotwordsScore)
|
||||
|
||||
c.blank_penalty = C.float(config.BlankPenalty)
|
||||
|
||||
c.rule_fsts = C.CString(config.RuleFsts)
|
||||
defer C.free(unsafe.Pointer(c.rule_fsts))
|
||||
|
||||
|
||||
@@ -105,6 +105,8 @@ 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.ctc_fst_decoder_config.graph =
|
||||
SHERPA_ONNX_OR(config->ctc_fst_decoder_config.graph, "");
|
||||
recognizer_config.ctc_fst_decoder_config.max_active =
|
||||
|
||||
@@ -142,6 +142,7 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user