From 6985a4626bb1034a80e08609a313913d2df48a29 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期四, 09 十一月 2023 11:33:29 +0800
Subject: [PATCH] Merge branch 'main' of github.com:alibaba-damo-academy/FunASR add

---
 runtime/onnxruntime/bin/funasr-onnx-2pass.cpp     |    2 +-
 runtime/onnxruntime/src/tokenizer.h               |    4 ++--
 funasr/bin/build_trainer.py                       |    7 +++++--
 runtime/onnxruntime/bin/funasr-onnx-2pass-rtf.cpp |    2 +-
 runtime/onnxruntime/src/tokenizer.cpp             |    8 ++++++--
 README.md                                         |    4 ++--
 6 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index e51d8bd..3f6b434 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@
 | [**Quick Start**](#quick-start)
 | [**Runtime**](./runtime/readme.md)
 | [**Model Zoo**](#model-zoo)
-| [**Contact**](#community-communication)
+| [**Contact**](#contact)
 
 
 <a name="highlights"></a>
@@ -126,7 +126,7 @@
 For more detailed information, please refer to the [service deployment documentation](runtime/readme.md).
 
 
-<a name="Community Communication"></a>
+<a name="contact"></a>
 ## Community Communication
 If you encounter problems in use, you can directly raise Issues on the github page.
 
diff --git a/funasr/bin/build_trainer.py b/funasr/bin/build_trainer.py
index 61af766..bda83ec 100644
--- a/funasr/bin/build_trainer.py
+++ b/funasr/bin/build_trainer.py
@@ -548,7 +548,10 @@
     init_param = modelscope_dict['init_model']
     cmvn_file = modelscope_dict['cmvn_file']
     seg_dict_file = modelscope_dict['seg_dict']
-    bpemodel = modelscope_dict['bpemodel']
+    if 'bpemodel' in modelscope_dict:
+        bpemodel = modelscope_dict['bpemodel']
+    else:
+        bpemodel = None
 
     # overwrite parameters
     with open(config) as f:
@@ -582,7 +585,7 @@
         args.seg_dict_file = seg_dict_file
     else:
         args.seg_dict_file = None
-    if os.path.exists(bpemodel):
+    if bpemodel is not None and os.path.exists(bpemodel):
         args.bpemodel = bpemodel
     else:
         args.bpemodel = None
diff --git a/runtime/onnxruntime/bin/funasr-onnx-2pass-rtf.cpp b/runtime/onnxruntime/bin/funasr-onnx-2pass-rtf.cpp
index 5bf8f18..c55c888 100644
--- a/runtime/onnxruntime/bin/funasr-onnx-2pass-rtf.cpp
+++ b/runtime/onnxruntime/bin/funasr-onnx-2pass-rtf.cpp
@@ -279,7 +279,7 @@
     // hotword file
     unordered_map<string, int> hws_map;
     std::string nn_hotwords_ = "";
-    std::string hotword_path = model_path.at(HOTWORD);
+    std::string hotword_path = hotword.getValue();
     LOG(INFO) << "hotword path: " << hotword_path;
     funasr::ExtractHws(hotword_path, hws_map, nn_hotwords_);
 
diff --git a/runtime/onnxruntime/bin/funasr-onnx-2pass.cpp b/runtime/onnxruntime/bin/funasr-onnx-2pass.cpp
index d015499..5af0b41 100644
--- a/runtime/onnxruntime/bin/funasr-onnx-2pass.cpp
+++ b/runtime/onnxruntime/bin/funasr-onnx-2pass.cpp
@@ -113,7 +113,7 @@
     // hotword file
     unordered_map<string, int> hws_map;
     std::string nn_hotwords_ = "";
-    std::string hotword_path = model_path.at(HOTWORD);
+    std::string hotword_path = hotword.getValue();
     LOG(INFO) << "hotword path: " << hotword_path;
     funasr::ExtractHws(hotword_path, hws_map, nn_hotwords_);
 
diff --git a/runtime/onnxruntime/src/tokenizer.cpp b/runtime/onnxruntime/src/tokenizer.cpp
index a111b91..f56601a 100644
--- a/runtime/onnxruntime/src/tokenizer.cpp
+++ b/runtime/onnxruntime/src/tokenizer.cpp
@@ -17,8 +17,12 @@
 
 CTokenizer::~CTokenizer()
 {
-	delete jieba_dict_trie_;
-    delete jieba_model_;
+	if (jieba_dict_trie_){
+		delete jieba_dict_trie_;
+	}
+	if (jieba_model_){
+    	delete jieba_model_;
+	}
 }
 
 void CTokenizer::SetJiebaRes(cppjieba::DictTrie *dict, cppjieba::HMMModel *hmm) {
diff --git a/runtime/onnxruntime/src/tokenizer.h b/runtime/onnxruntime/src/tokenizer.h
index 149161b..166061b 100644
--- a/runtime/onnxruntime/src/tokenizer.h
+++ b/runtime/onnxruntime/src/tokenizer.h
@@ -17,8 +17,8 @@
 	vector<string>   m_id2token,m_id2punc;
 	map<string, int>  m_token2id,m_punc2id;
 
-	cppjieba::DictTrie *jieba_dict_trie_;
-    cppjieba::HMMModel *jieba_model_;
+	cppjieba::DictTrie *jieba_dict_trie_=nullptr;
+    cppjieba::HMMModel *jieba_model_=nullptr;
 	cppjieba::Jieba jieba_processor_;
 
 public:

--
Gitblit v1.9.1