From 6d6c6e3c79216896c45ff87b4bdfd8226a24924e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=BE=E8=81=AA?= Date: Tue, 14 Nov 2023 19:22:17 +0800 Subject: [PATCH] update docs; update run_server.sh; fix initlm --- runtime/onnxruntime/readme.md | 6 +++++- runtime/onnxruntime/src/paraformer.cpp | 10 +++++++--- runtime/run_server.sh | 3 +++ runtime/run_server_2pass.sh | 3 +++ runtime/websocket/readme_zh.md | 4 +++- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/runtime/onnxruntime/readme.md b/runtime/onnxruntime/readme.md index cf62f3ee5..769010aa8 100644 --- a/runtime/onnxruntime/readme.md +++ b/runtime/onnxruntime/readme.md @@ -53,4 +53,8 @@ mkdir build 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 b6babfefe..11ed0ff10 100644 --- a/runtime/onnxruntime/src/paraformer.cpp +++ b/runtime/onnxruntime/src/paraformer.cpp @@ -191,9 +191,13 @@ void Paraformer::InitLm(const std::string &lm_file, try { lm_ = std::shared_ptr>( fst::Fst::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 ab1cff76c..120193bed 100644 --- a/runtime/run_server.sh +++ b/runtime/run_server.sh @@ -6,6 +6,7 @@ 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" @@ -25,6 +26,7 @@ if [ -z "$certfile" ] || [ "$certfile" -eq 0 ]; then --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 @@ else --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 c8e218799..e01770893 100644 --- a/runtime/run_server_2pass.sh +++ b/runtime/run_server_2pass.sh @@ -6,6 +6,7 @@ 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" @@ -24,6 +25,7 @@ if [ -z "$certfile" ] || [ "$certfile" -eq 0 ]; then --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 @@ else --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 c212e8669..138c84245 100644 --- a/runtime/websocket/readme_zh.md +++ b/runtime/websocket/readme_zh.md @@ -72,5 +72,7 @@ mkdir build 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相关的DLL库至: FunASR/runtime/onnxruntime/build/bin/Debug