Fix building (#1343)
This commit is contained in:
@@ -22,6 +22,8 @@ namespace SherpaOnnx
|
||||
ModelType = "";
|
||||
ModelingUnit = "cjkchar";
|
||||
BpeVocab = "";
|
||||
TokensBuf = "";
|
||||
TokensBufSize = 0;
|
||||
}
|
||||
|
||||
public OnlineTransducerModelConfig Transducer;
|
||||
@@ -48,6 +50,11 @@ namespace SherpaOnnx
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string BpeVocab;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string TokensBuf;
|
||||
|
||||
public int TokensBufSize;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace SherpaOnnx
|
||||
RuleFsts = "";
|
||||
RuleFars = "";
|
||||
BlankPenalty = 0.0F;
|
||||
HotwordsBuf = "";
|
||||
HotwordsBufSize = 0;
|
||||
}
|
||||
public FeatureConfig FeatConfig;
|
||||
public OnlineModelConfig ModelConfig;
|
||||
@@ -72,5 +74,10 @@ namespace SherpaOnnx
|
||||
public string RuleFars;
|
||||
|
||||
public float BlankPenalty;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string HotwordsBuf;
|
||||
|
||||
public int HotwordsBufSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,8 @@ type OnlineModelConfig struct {
|
||||
ModelType string // Optional. You can specify it for faster model initialization
|
||||
ModelingUnit string // Optional. cjkchar, bpe, cjkchar+bpe
|
||||
BpeVocab string // Optional.
|
||||
TokensBuf string // Optional.
|
||||
TokensBufSize int // Optional.
|
||||
}
|
||||
|
||||
// Configuration for the feature extractor
|
||||
@@ -133,6 +135,8 @@ type OnlineRecognizerConfig struct {
|
||||
CtcFstDecoderConfig OnlineCtcFstDecoderConfig
|
||||
RuleFsts string
|
||||
RuleFars string
|
||||
HotwordsBuf string
|
||||
HotwordsBufSize int
|
||||
}
|
||||
|
||||
// It contains the recognition result for a online stream.
|
||||
@@ -184,6 +188,11 @@ func NewOnlineRecognizer(config *OnlineRecognizerConfig) *OnlineRecognizer {
|
||||
c.model_config.tokens = C.CString(config.ModelConfig.Tokens)
|
||||
defer C.free(unsafe.Pointer(c.model_config.tokens))
|
||||
|
||||
c.model_config.tokens_buf = C.CString(config.ModelConfig.TokensBuf)
|
||||
defer C.free(unsafe.Pointer(c.model_config.tokens_buf))
|
||||
|
||||
c.model_config.tokens_buf_size = C.int(config.ModelConfig.TokensBufSize)
|
||||
|
||||
c.model_config.num_threads = C.int(config.ModelConfig.NumThreads)
|
||||
|
||||
c.model_config.provider = C.CString(config.ModelConfig.Provider)
|
||||
@@ -212,6 +221,11 @@ func NewOnlineRecognizer(config *OnlineRecognizerConfig) *OnlineRecognizer {
|
||||
c.hotwords_file = C.CString(config.HotwordsFile)
|
||||
defer C.free(unsafe.Pointer(c.hotwords_file))
|
||||
|
||||
c.hotwords_buf = C.CString(config.HotwordsBuf)
|
||||
defer C.free(unsafe.Pointer(c.hotwords_buf))
|
||||
|
||||
c.hotwords_buf_size = C.int(config.HotwordsBufSize)
|
||||
|
||||
c.hotwords_score = C.float(config.HotwordsScore)
|
||||
c.blank_penalty = C.float(config.BlankPenalty)
|
||||
|
||||
|
||||
@@ -120,6 +120,8 @@ SherpaOnnxOnlineModelConfig GetOnlineModelConfig(Napi::Object obj) {
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(model_type, modelType);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(modeling_unit, modelingUnit);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(bpe_vocab, bpeVocab);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(tokens_buf, tokensBuf);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_INT32(tokens_buf_size, tokensBufSize);
|
||||
|
||||
return c;
|
||||
}
|
||||
@@ -192,6 +194,8 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper(
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fsts, ruleFsts);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fars, ruleFars);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_FLOAT(blank_penalty, blankPenalty);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_STR(hotwords_buf, hotwordsBuf);
|
||||
SHERPA_ONNX_ASSIGN_ATTR_INT32(hotwords_buf_size, hotwordsBufSize);
|
||||
|
||||
c.ctc_fst_decoder_config = GetCtcFstDecoderConfig(o);
|
||||
|
||||
@@ -241,6 +245,10 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper(
|
||||
delete[] c.model_config.bpe_vocab;
|
||||
}
|
||||
|
||||
if (c.model_config.tokens_buf) {
|
||||
delete[] c.model_config.tokens_buf;
|
||||
}
|
||||
|
||||
if (c.decoding_method) {
|
||||
delete[] c.decoding_method;
|
||||
}
|
||||
@@ -257,6 +265,10 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper(
|
||||
delete[] c.rule_fars;
|
||||
}
|
||||
|
||||
if (c.hotwords_buf) {
|
||||
delete[] c.hotwords_buf;
|
||||
}
|
||||
|
||||
if (c.ctc_fst_decoder_config.graph) {
|
||||
delete[] c.ctc_fst_decoder_config.graph;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user