From b6190f04ffe0329df2e9225f9f9dbf4f40b12f91 Mon Sep 17 00:00:00 2001
From: 雾聪 <wucong.lyb@alibaba-inc.com>
Date: 星期二, 05 十二月 2023 14:22:10 +0800
Subject: [PATCH] automatically configure parameters such as decoder-thread-num

---
 runtime/run_server_2pass.sh |   31 +++++----------
 runtime/run_server.sh       |   31 +++++----------
 2 files changed, 22 insertions(+), 40 deletions(-)

diff --git a/runtime/run_server.sh b/runtime/run_server.sh
index 120193b..aa33f0f 100644
--- a/runtime/run_server.sh
+++ b/runtime/run_server.sh
@@ -5,33 +5,24 @@
 punc_dir="damo/punc_ct-transformer_cn-en-common-vocab471067-large-onnx"
 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"
 keyfile="../../../ssl_key/server.key"
 hotword="../../hotwords.txt"
+# set decoder_thread_num
+decoder_thread_num=$(cat /proc/cpuinfo | grep "processor"|wc -l) || { echo "Get cpuinfo failed. Set decoder_thread_num = 32"; decoder_thread_num=32; }
+multiple_io=16
+io_thread_num=$(( (decoder_thread_num + multiple_io - 1) / multiple_io ))
+model_thread_num=1
 
 . ../egs/aishell/transformer/utils/parse_options.sh || exit 1;
 
+if [ -z "$certfile" ] || [ "$certfile" = "0" ]; then
+  certfile=""
+  keyfile=""
+fi
+
 cd /workspace/FunASR/runtime/websocket/build/bin
-if [ -z "$certfile" ] || [ "$certfile" -eq 0 ]; then
-./funasr-wss-server  \
-  --download-model-dir "${download_model_dir}" \
-  --model-dir "${model_dir}" \
-  --vad-dir "${vad_dir}" \
-  --punc-dir "${punc_dir}" \
-  --itn-dir "${itn_dir}" \
-  --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 "" \
-  --hotword "${hotword}"
-else
 ./funasr-wss-server  \
   --download-model-dir "${download_model_dir}" \
   --model-dir "${model_dir}" \
@@ -46,4 +37,4 @@
   --certfile  "${certfile}" \
   --keyfile "${keyfile}" \
   --hotword "${hotword}"
-fi
+
diff --git a/runtime/run_server_2pass.sh b/runtime/run_server_2pass.sh
index e017708..95a3bf7 100644
--- a/runtime/run_server_2pass.sh
+++ b/runtime/run_server_2pass.sh
@@ -5,33 +5,24 @@
 vad_dir="damo/speech_fsmn_vad_zh-cn-16k-common-onnx"
 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"
 keyfile="../../../ssl_key/server.key"
 hotword="../../hotwords.txt"
+# set decoder_thread_num
+decoder_thread_num=$(cat /proc/cpuinfo | grep "processor"|wc -l) || { echo "Get cpuinfo failed. Set decoder_thread_num = 32"; decoder_thread_num=32; }
+multiple_io=16
+io_thread_num=$(( (decoder_thread_num + multiple_io - 1) / multiple_io ))
+model_thread_num=1
 
 . ../egs/aishell/transformer/utils/parse_options.sh || exit 1;
 
+if [ -z "$certfile" ] || [ "$certfile" = "0" ]; then
+  certfile=""
+  keyfile=""
+fi
+
 cd /workspace/FunASR/runtime/websocket/build/bin
-if [ -z "$certfile" ] || [ "$certfile" -eq 0 ]; then
-./funasr-wss-server-2pass  \
-  --download-model-dir "${download_model_dir}" \
-  --model-dir "${model_dir}" \
-  --online-model-dir "${online_model_dir}" \
-  --vad-dir "${vad_dir}" \
-  --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  "" \
-  --keyfile "" \
-  --hotword "${hotword}"
-else
 ./funasr-wss-server-2pass  \
   --download-model-dir "${download_model_dir}" \
   --model-dir "${model_dir}" \
@@ -46,4 +37,4 @@
   --certfile  "${certfile}" \
   --keyfile "${keyfile}" \
   --hotword "${hotword}"
-fi
+

--
Gitblit v1.9.1