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