From b9bcf1f093c3053fdc4e2cf4a1d38e27bbf429fb Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期四, 19 十月 2023 14:03:48 +0800
Subject: [PATCH] docs

---
 funasr/runtime/onnxruntime/src/tpass-stream.cpp |   36 +++++++++++++++++++++++++++++++++---
 1 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/funasr/runtime/onnxruntime/src/tpass-stream.cpp b/funasr/runtime/onnxruntime/src/tpass-stream.cpp
index 9377286..a3e1b0e 100644
--- a/funasr/runtime/onnxruntime/src/tpass-stream.cpp
+++ b/funasr/runtime/onnxruntime/src/tpass-stream.cpp
@@ -1,5 +1,4 @@
 #include "precomp.h"
-#include <unistd.h>
 
 namespace funasr {
 TpassStream::TpassStream(std::map<std::string, std::string>& model_path, int thread_num)
@@ -36,6 +35,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 +61,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 +88,24 @@
             use_punc = true;
         }
     }
+#if !defined(__APPLE__)
+    // 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;
+        }
+    }
+#endif
+      
 }
 
 TpassStream *CreateTpassStream(std::map<std::string, std::string>& model_path, int thread_num)
@@ -84,4 +114,4 @@
     mm = new TpassStream(model_path, thread_num);
     return mm;
 }
-} // namespace funasr
\ No newline at end of file
+} // namespace funasr

--
Gitblit v1.9.1