From 9fcb3cc06b4e324f0913d2f61b89becc2baeef1b Mon Sep 17 00:00:00 2001
From: hnluo <haoneng.lhn@alibaba-inc.com>
Date: 星期一, 11 九月 2023 17:40:03 +0800
Subject: [PATCH] Merge pull request #932 from alibaba-damo-academy/dev_lhn
---
funasr/runtime/websocket/funasr-wss-server.cpp | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/funasr/runtime/websocket/funasr-wss-server.cpp b/funasr/runtime/websocket/funasr-wss-server.cpp
index eb1f48c..f9968ca 100644
--- a/funasr/runtime/websocket/funasr-wss-server.cpp
+++ b/funasr/runtime/websocket/funasr-wss-server.cpp
@@ -79,7 +79,7 @@
TCLAP::ValueArg<int> decoder_thread_num(
"", "decoder-thread-num", "decoder thread num", false, 8, "int");
TCLAP::ValueArg<int> model_thread_num("", "model-thread-num",
- "model thread num", false, 1, "int");
+ "model thread num", false, 4, "int");
TCLAP::ValueArg<std::string> certfile("", "certfile",
"default: ../../../ssl_key/server.crt, path of certficate for WSS connection. if it is empty, it will be in WS mode.",
@@ -152,7 +152,7 @@
int ret = system(python_cmd_vad.c_str());
if(ret !=0){
- LOG(INFO) << "Failed to download model from modelscope. If you set local model path, you can ignore the errors.";
+ LOG(INFO) << "Failed to download model from modelscope. If you set local vad model path, you can ignore the errors.";
}
down_vad_model = down_vad_path+"/model_quant.onnx";
if(s_vad_quant=="false" || s_vad_quant=="False" || s_vad_quant=="FALSE"){
@@ -173,13 +173,25 @@
if(model_dir.isSet() && !s_asr_path.empty()){
std::string python_cmd_asr;
std::string down_asr_path;
- std::string down_asr_model;
+ std::string down_asr_model;
if (access(s_asr_path.c_str(), F_OK) == 0){
// local
python_cmd_asr = python_cmd + " --model-name " + s_asr_path + " --export-dir ./ " + " --model_revision " + model_path["model-revision"];
down_asr_path = s_asr_path;
}else{
+ size_t found = s_asr_path.find("speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404");
+ if (found != std::string::npos) {
+ model_path["model-revision"]="v1.2.4";
+ }else{
+ found = s_asr_path.find("speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404");
+ if (found != std::string::npos) {
+ model_path["model-revision"]="v1.0.3";
+ model_path[QUANTIZE]=false;
+ s_asr_quant = false;
+ }
+ }
+
// modelscope
LOG(INFO) << "Download model: " << s_asr_path << " from modelscope: ";
python_cmd_asr = python_cmd + " --model-name " + s_asr_path + " --export-dir " + s_download_model_dir + " --model_revision " + model_path["model-revision"];
@@ -188,7 +200,7 @@
int ret = system(python_cmd_asr.c_str());
if(ret !=0){
- LOG(INFO) << "Failed to download model from modelscope. If you set local model path, you can ignore the errors.";
+ LOG(INFO) << "Failed to download model from modelscope. If you set local asr model path, you can ignore the errors.";
}
down_asr_model = down_asr_path+"/model_quant.onnx";
if(s_asr_quant=="false" || s_asr_quant=="False" || s_asr_quant=="FALSE"){
@@ -196,7 +208,7 @@
}
if (access(down_asr_model.c_str(), F_OK) != 0){
- LOG(ERROR) << down_asr_model << " do not exists.";
+ LOG(ERROR) << down_asr_model << " do not exists.";
exit(-1);
}else{
model_path[MODEL_DIR]=down_asr_path;
@@ -224,7 +236,7 @@
int ret = system(python_cmd_punc.c_str());
if(ret !=0){
- LOG(INFO) << "Failed to download model from modelscope. If you set local model path, you can ignore the errors.";
+ LOG(INFO) << "Failed to download model from modelscope. If you set local punc model path, you can ignore the errors.";
}
down_punc_model = down_punc_path+"/model_quant.onnx";
if(s_punc_quant=="false" || s_punc_quant=="False" || s_punc_quant=="FALSE"){
@@ -278,6 +290,7 @@
server server_; // server for websocket
wss_server wss_server_;
if (is_ssl) {
+ LOG(INFO)<< "SSL is opened!";
wss_server_.init_asio(&io_server); // init asio
wss_server_.set_reuse_addr(
true); // reuse address as we create multiple threads
@@ -290,6 +303,7 @@
websocket_srv.initAsr(model_path, s_model_thread_num); // init asr model
} else {
+ LOG(INFO)<< "SSL is closed!";
server_.init_asio(&io_server); // init asio
server_.set_reuse_addr(
true); // reuse address as we create multiple threads
--
Gitblit v1.9.1