From 6d6c6e3c79216896c45ff87b4bdfd8226a24924e Mon Sep 17 00:00:00 2001
From: 雾聪 <wucong.lyb@alibaba-inc.com>
Date: 星期二, 14 十一月 2023 19:22:17 +0800
Subject: [PATCH] update docs; update run_server.sh; fix initlm

---
 runtime/onnxruntime/readme.md          |    6 +++++-
 runtime/run_server_2pass.sh            |    3 +++
 runtime/run_server.sh                  |    3 +++
 runtime/websocket/readme_zh.md         |    4 +++-
 runtime/onnxruntime/src/paraformer.cpp |   10 +++++++---
 5 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/runtime/onnxruntime/readme.md b/runtime/onnxruntime/readme.md
index cf62f3e..769010a 100644
--- a/runtime/onnxruntime/readme.md
+++ b/runtime/onnxruntime/readme.md
@@ -53,4 +53,8 @@
 cd build
 cmake ../ -D FFMPEG_DIR=d:/ffmpeg-master-latest-win64-gpl-shared -D ONNXRUNTIME_DIR=d:/onnxruntime-win-x64-1.16.1
 ```
-Visual Studio open FunASR/runtime/onnxruntime/build/FunASROnnx.sln start build
+
+Visual Studio open FunASR/runtime/onnxruntime/build/FunASROnnx.sln start build. 
+After compilation, the executable file is located here: FunASR/runtime/onnxruntime/build/bin/Debug.
+Copy the required DLL libraries from (onnxruntime-win-x64-1.16.1/lib, ffmpeg-master-latest-win64-gpl-shared/bin) to this location: FunASR/runtime/onnxruntime/build/bin/Debug
+
diff --git a/runtime/onnxruntime/src/paraformer.cpp b/runtime/onnxruntime/src/paraformer.cpp
index b6babfe..11ed0ff 100644
--- a/runtime/onnxruntime/src/paraformer.cpp
+++ b/runtime/onnxruntime/src/paraformer.cpp
@@ -191,9 +191,13 @@
     try {
         lm_ = std::shared_ptr<fst::Fst<fst::StdArc>>(
             fst::Fst<fst::StdArc>::Read(lm_file));
-        if (vocab) { delete vocab; }
-        vocab = new Vocab(lm_cfg_file.c_str());
-        LOG(INFO) << "Successfully load lm file " << lm_file;
+        if (lm_){
+            if (vocab) { delete vocab; }
+            vocab = new Vocab(lm_cfg_file.c_str());
+            LOG(INFO) << "Successfully load lm file " << lm_file;
+        }else{
+            LOG(ERROR) << "Failed to load lm file " << lm_file;
+        }
     } catch (std::exception const &e) {
         LOG(ERROR) << "Error when load lm file: " << e.what();
         exit(0);
diff --git a/runtime/run_server.sh b/runtime/run_server.sh
index ab1cff7..120193b 100644
--- a/runtime/run_server.sh
+++ b/runtime/run_server.sh
@@ -6,6 +6,7 @@
 itn_dir="thuduj12/fst_itn_zh"
 lm_dir="damo/speech_ngram_lm_zh-cn-ai-wesp-fst"
 decoder_thread_num=32
+model_thread_num=1
 io_thread_num=8
 port=10095
 certfile="../../../ssl_key/server.crt"
@@ -25,6 +26,7 @@
   --lm-dir "${lm_dir}" \
   --decoder-thread-num ${decoder_thread_num} \
   --io-thread-num  ${io_thread_num} \
+  --model-thread-num ${model_thread_num} \
   --port ${port} \
   --certfile  "" \
   --keyfile "" \
@@ -38,6 +40,7 @@
   --itn-dir "${itn_dir}" \
   --lm-dir "${lm_dir}" \
   --decoder-thread-num ${decoder_thread_num} \
+  --model-thread-num ${model_thread_num} \
   --io-thread-num  ${io_thread_num} \
   --port ${port} \
   --certfile  "${certfile}" \
diff --git a/runtime/run_server_2pass.sh b/runtime/run_server_2pass.sh
index c8e2187..e017708 100644
--- a/runtime/run_server_2pass.sh
+++ b/runtime/run_server_2pass.sh
@@ -6,6 +6,7 @@
 punc_dir="damo/punc_ct-transformer_zh-cn-common-vad_realtime-vocab272727-onnx"
 itn_dir="thuduj12/fst_itn_zh"
 decoder_thread_num=32
+model_thread_num=1
 io_thread_num=8
 port=10095
 certfile="../../../ssl_key/server.crt"
@@ -24,6 +25,7 @@
   --punc-dir "${punc_dir}" \
   --itn-dir "${itn_dir}" \
   --decoder-thread-num ${decoder_thread_num} \
+  --model-thread-num ${model_thread_num} \
   --io-thread-num  ${io_thread_num} \
   --port ${port} \
   --certfile  "" \
@@ -38,6 +40,7 @@
   --punc-dir "${punc_dir}" \
   --itn-dir "${itn_dir}" \
   --decoder-thread-num ${decoder_thread_num} \
+  --model-thread-num ${model_thread_num} \
   --io-thread-num  ${io_thread_num} \
   --port ${port} \
   --certfile  "${certfile}" \
diff --git a/runtime/websocket/readme_zh.md b/runtime/websocket/readme_zh.md
index c212e86..138c842 100644
--- a/runtime/websocket/readme_zh.md
+++ b/runtime/websocket/readme_zh.md
@@ -72,5 +72,7 @@
 cd build
 cmake ../ -D OPENSSL_ROOT_DIR=d:/openssl-1.1.1w -D FFMPEG_DIR=d:/ffmpeg-master-latest-win64-gpl-shared -D ONNXRUNTIME_DIR=d:/onnxruntime-win-x64-1.16.1
 ```
-Visual Studio 鎵撳紑 FunASR/runtime/websocket/build/FunASRWebscoket.sln 瀹屾垚缂栬瘧
+Visual Studio 鎵撳紑 FunASR/runtime/websocket/build/FunASRWebscoket.sln 瀹屾垚缂栬瘧锛�
+缂栬瘧鍚庣殑鍙墽琛屾枃浠朵綅浜庯細FunASR/runtime/websocket/build/bin/Debug;
+浠� onnxruntime-win-x64-1.16.1/lib, ffmpeg-master-latest-win64-gpl-shared/bin copy鐩稿叧鐨凞LL搴撹嚦: FunASR/runtime/onnxruntime/build/bin/Debug
 

--
Gitblit v1.9.1