From 0b5ab0709e8292447b314f4f02c74becafd6ce76 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期二, 19 九月 2023 12:33:53 +0800
Subject: [PATCH] wechat
---
funasr/runtime/onnxruntime/src/tpass-stream.cpp | 32 +++++++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/funasr/runtime/onnxruntime/src/tpass-stream.cpp b/funasr/runtime/onnxruntime/src/tpass-stream.cpp
index 9377286..31ddde5 100644
--- a/funasr/runtime/onnxruntime/src/tpass-stream.cpp
+++ b/funasr/runtime/onnxruntime/src/tpass-stream.cpp
@@ -36,6 +36,20 @@
string de_model_path;
string am_cmvn_path;
string am_config_path;
+ string hw_compile_model_path;
+ string seg_dict_path;
+
+ asr_handle = make_unique<Paraformer>();
+
+ bool enable_hotword = false;
+ hw_compile_model_path = PathAppend(model_path.at(MODEL_DIR), MODEL_EB_NAME);
+ seg_dict_path = PathAppend(model_path.at(MODEL_DIR), MODEL_SEG_DICT);
+ if ((access(hw_compile_model_path.c_str(), F_OK) == 0) &&
+ (access(seg_dict_path.c_str(), F_OK) == 0)) { // if model_eb.onnx exist, hotword enabled
+ enable_hotword = true;
+ asr_handle->InitHwCompiler(hw_compile_model_path, thread_num);
+ asr_handle->InitSegDict(seg_dict_path);
+ }
am_model_path = PathAppend(model_path.at(OFFLINE_MODEL_DIR), MODEL_NAME);
en_model_path = PathAppend(model_path.at(ONLINE_MODEL_DIR), ENCODER_NAME);
@@ -48,7 +62,6 @@
am_cmvn_path = PathAppend(model_path.at(ONLINE_MODEL_DIR), AM_CMVN_NAME);
am_config_path = PathAppend(model_path.at(ONLINE_MODEL_DIR), AM_CONFIG_NAME);
- asr_handle = make_unique<Paraformer>();
asr_handle->InitAsr(am_model_path, en_model_path, de_model_path, am_cmvn_path, am_config_path, thread_num);
}else{
LOG(ERROR) <<"Can not find offline-model-dir or online-model-dir";
@@ -76,6 +89,23 @@
use_punc = true;
}
}
+
+ // Optional: ITN, here we just support language_type=MandarinEnglish
+ if(model_path.find(ITN_DIR) != model_path.end()){
+ string itn_tagger_path = PathAppend(model_path.at(ITN_DIR), ITN_TAGGER_NAME);
+ string itn_verbalizer_path = PathAppend(model_path.at(ITN_DIR), ITN_VERBALIZER_NAME);
+
+ if (access(itn_tagger_path.c_str(), F_OK) != 0 ||
+ access(itn_verbalizer_path.c_str(), F_OK) != 0 )
+ {
+ LOG(INFO) << "ITN model file is not exist, skip load ITN model.";
+ }else{
+ itn_handle = make_unique<ITNProcessor>();
+ itn_handle->InitITN(itn_tagger_path, itn_verbalizer_path, thread_num);
+ use_itn = true;
+ }
+ }
+
}
TpassStream *CreateTpassStream(std::map<std::string, std::string>& model_path, int thread_num)
--
Gitblit v1.9.1