re-pull-request allow tokens and hotwords be loaded from buffered string driectly (#1339)

Co-authored-by: xiao <shawl336@163.com>
This commit is contained in:
lxiao336
2024-09-13 09:58:17 +08:00
committed by GitHub
parent 6b6e7635ed
commit 65cfa7548a
12 changed files with 414 additions and 16 deletions

View File

@@ -44,10 +44,16 @@ class OnlineRecognizerTransducerNeMoImpl : public OnlineRecognizerImpl {
const OnlineRecognizerConfig &config)
: OnlineRecognizerImpl(config),
config_(config),
symbol_table_(config.model_config.tokens),
endpoint_(config_.endpoint_config),
model_(
std::make_unique<OnlineTransducerNeMoModel>(config.model_config)) {
if (!config.model_config.tokens_buf.empty()) {
symbol_table_ = SymbolTable(config.model_config.tokens_buf, false);
} else {
/// assuming tokens_buf and tokens are guaranteed not being both empty
symbol_table_ = SymbolTable(config.model_config.tokens, true);
}
if (config.decoding_method == "greedy_search") {
decoder_ = std::make_unique<OnlineTransducerGreedySearchNeMoDecoder>(
model_.get(), config_.blank_penalty);