Allow more online models to load tokens file from the memory (#1352)
Co-authored-by: xiao <shawl336@6163.com>
This commit is contained in:
@@ -667,6 +667,12 @@ SherpaOnnxKeywordSpotter *SherpaOnnxCreateKeywordSpotter(
|
||||
|
||||
spotter_config.model_config.tokens =
|
||||
SHERPA_ONNX_OR(config->model_config.tokens, "");
|
||||
if (config->model_config.tokens_buf &&
|
||||
config->model_config.tokens_buf_size > 0) {
|
||||
spotter_config.model_config.tokens_buf = std::string(
|
||||
config->model_config.tokens_buf, config->model_config.tokens_buf_size);
|
||||
}
|
||||
|
||||
spotter_config.model_config.num_threads =
|
||||
SHERPA_ONNX_OR(config->model_config.num_threads, 1);
|
||||
spotter_config.model_config.provider_config.provider =
|
||||
@@ -691,6 +697,10 @@ SherpaOnnxKeywordSpotter *SherpaOnnxCreateKeywordSpotter(
|
||||
SHERPA_ONNX_OR(config->keywords_threshold, 0.25);
|
||||
|
||||
spotter_config.keywords_file = SHERPA_ONNX_OR(config->keywords_file, "");
|
||||
if (config->keywords_buf && config->keywords_buf_size > 0) {
|
||||
spotter_config.keywords_buf =
|
||||
std::string(config->keywords_buf, config->keywords_buf_size);
|
||||
}
|
||||
|
||||
if (config->model_config.debug) {
|
||||
SHERPA_ONNX_LOGE("%s\n", spotter_config.ToString().c_str());
|
||||
|
||||
@@ -88,8 +88,8 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineModelConfig {
|
||||
// - cjkchar+bpe
|
||||
const char *modeling_unit;
|
||||
const char *bpe_vocab;
|
||||
/// if non-null, loading the tokens from the buffered string directly in
|
||||
/// prioriy
|
||||
/// if non-null, loading the tokens from the buffer instead of from the
|
||||
/// "tokens" file
|
||||
const char *tokens_buf;
|
||||
/// byte size excluding the trailing '\0'
|
||||
int32_t tokens_buf_size;
|
||||
@@ -637,6 +637,11 @@ SHERPA_ONNX_API typedef struct SherpaOnnxKeywordSpotterConfig {
|
||||
float keywords_score;
|
||||
float keywords_threshold;
|
||||
const char *keywords_file;
|
||||
/// if non-null, loading the keywords from the buffer instead of from the
|
||||
/// keywords_file
|
||||
const char *keywords_buf;
|
||||
/// byte size excluding the trailing '\0'
|
||||
int32_t keywords_buf_size;
|
||||
} SherpaOnnxKeywordSpotterConfig;
|
||||
|
||||
SHERPA_ONNX_API typedef struct SherpaOnnxKeywordSpotter
|
||||
|
||||
Reference in New Issue
Block a user