Committed by
GitHub
feat: addition of blank_penalty config in online_recognizer (#1232)
正在显示
3 个修改的文件
包含
8 行增加
和
0 行删除
| @@ -129,6 +129,7 @@ type OnlineRecognizerConfig struct { | @@ -129,6 +129,7 @@ type OnlineRecognizerConfig struct { | ||
| 129 | Rule3MinUtteranceLength float32 | 129 | Rule3MinUtteranceLength float32 |
| 130 | HotwordsFile string | 130 | HotwordsFile string |
| 131 | HotwordsScore float32 | 131 | HotwordsScore float32 |
| 132 | + BlankPenalty float32 | ||
| 132 | CtcFstDecoderConfig OnlineCtcFstDecoderConfig | 133 | CtcFstDecoderConfig OnlineCtcFstDecoderConfig |
| 133 | RuleFsts string | 134 | RuleFsts string |
| 134 | RuleFars string | 135 | RuleFars string |
| @@ -212,6 +213,7 @@ func NewOnlineRecognizer(config *OnlineRecognizerConfig) *OnlineRecognizer { | @@ -212,6 +213,7 @@ func NewOnlineRecognizer(config *OnlineRecognizerConfig) *OnlineRecognizer { | ||
| 212 | defer C.free(unsafe.Pointer(c.hotwords_file)) | 213 | defer C.free(unsafe.Pointer(c.hotwords_file)) |
| 213 | 214 | ||
| 214 | c.hotwords_score = C.float(config.HotwordsScore) | 215 | c.hotwords_score = C.float(config.HotwordsScore) |
| 216 | + c.blank_penalty = C.float(config.BlankPenalty) | ||
| 215 | 217 | ||
| 216 | c.rule_fsts = C.CString(config.RuleFsts) | 218 | c.rule_fsts = C.CString(config.RuleFsts) |
| 217 | defer C.free(unsafe.Pointer(c.rule_fsts)) | 219 | defer C.free(unsafe.Pointer(c.rule_fsts)) |
| @@ -421,6 +423,7 @@ type OfflineRecognizerConfig struct { | @@ -421,6 +423,7 @@ type OfflineRecognizerConfig struct { | ||
| 421 | MaxActivePaths int | 423 | MaxActivePaths int |
| 422 | HotwordsFile string | 424 | HotwordsFile string |
| 423 | HotwordsScore float32 | 425 | HotwordsScore float32 |
| 426 | + BlankPenalty float32 | ||
| 424 | RuleFsts string | 427 | RuleFsts string |
| 425 | RuleFars string | 428 | RuleFars string |
| 426 | } | 429 | } |
| @@ -530,6 +533,8 @@ func NewOfflineRecognizer(config *OfflineRecognizerConfig) *OfflineRecognizer { | @@ -530,6 +533,8 @@ func NewOfflineRecognizer(config *OfflineRecognizerConfig) *OfflineRecognizer { | ||
| 530 | 533 | ||
| 531 | c.hotwords_score = C.float(config.HotwordsScore) | 534 | c.hotwords_score = C.float(config.HotwordsScore) |
| 532 | 535 | ||
| 536 | + c.blank_penalty = C.float(config.BlankPenalty) | ||
| 537 | + | ||
| 533 | c.rule_fsts = C.CString(config.RuleFsts) | 538 | c.rule_fsts = C.CString(config.RuleFsts) |
| 534 | defer C.free(unsafe.Pointer(c.rule_fsts)) | 539 | defer C.free(unsafe.Pointer(c.rule_fsts)) |
| 535 | 540 |
| @@ -105,6 +105,8 @@ SherpaOnnxOnlineRecognizer *SherpaOnnxCreateOnlineRecognizer( | @@ -105,6 +105,8 @@ SherpaOnnxOnlineRecognizer *SherpaOnnxCreateOnlineRecognizer( | ||
| 105 | recognizer_config.hotwords_score = | 105 | recognizer_config.hotwords_score = |
| 106 | SHERPA_ONNX_OR(config->hotwords_score, 1.5); | 106 | SHERPA_ONNX_OR(config->hotwords_score, 1.5); |
| 107 | 107 | ||
| 108 | + recognizer_config.blank_penalty = SHERPA_ONNX_OR(config->blank_penalty, 0.0); | ||
| 109 | + | ||
| 108 | recognizer_config.ctc_fst_decoder_config.graph = | 110 | recognizer_config.ctc_fst_decoder_config.graph = |
| 109 | SHERPA_ONNX_OR(config->ctc_fst_decoder_config.graph, ""); | 111 | SHERPA_ONNX_OR(config->ctc_fst_decoder_config.graph, ""); |
| 110 | recognizer_config.ctc_fst_decoder_config.max_active = | 112 | recognizer_config.ctc_fst_decoder_config.max_active = |
| @@ -142,6 +142,7 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineRecognizerConfig { | @@ -142,6 +142,7 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineRecognizerConfig { | ||
| 142 | 142 | ||
| 143 | /// Bonus score for each token in hotwords. | 143 | /// Bonus score for each token in hotwords. |
| 144 | float hotwords_score; | 144 | float hotwords_score; |
| 145 | + float blank_penalty; | ||
| 145 | 146 | ||
| 146 | SherpaOnnxOnlineCtcFstDecoderConfig ctc_fst_decoder_config; | 147 | SherpaOnnxOnlineCtcFstDecoderConfig ctc_fst_decoder_config; |
| 147 | const char *rule_fsts; | 148 | const char *rule_fsts; |
-
请 注册 或 登录 后发表评论