From eff2570faf3dae7908db87edf4ef1a6ea88e5b33 Mon Sep 17 00:00:00 2001
From: cdevelop <cdevelop@qq.com>
Date: 星期三, 15 十一月 2023 19:46:00 +0800
Subject: [PATCH] 解决windwos 加载lm模型失败 (#1093)
---
runtime/websocket/bin/funasr-wss-server.cpp | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/runtime/websocket/bin/funasr-wss-server.cpp b/runtime/websocket/bin/funasr-wss-server.cpp
index c285fd3..916d115 100644
--- a/runtime/websocket/bin/funasr-wss-server.cpp
+++ b/runtime/websocket/bin/funasr-wss-server.cpp
@@ -11,7 +11,11 @@
// [--vad-quant <string>] [--vad-dir <string>] [--quantize
// <string>] --model-dir <string> [--] [--version] [-h]
#include "websocket-server.h"
+#ifdef _WIN32
+#include "win_func.h"
+#else
#include <unistd.h>
+#endif
#include <fstream>
#include "util.h"
@@ -108,7 +112,7 @@
TCLAP::ValueArg<float> am_scale("", AM_SCALE, "the acoustic scale for beam searching ", false, 10.0, "float");
TCLAP::ValueArg<std::string> lm_dir("", LM_DIR,
- "the LM model path, which contains compiled models: TLG.fst, config.yaml ", false, "", "string");
+ "the LM model path, which contains compiled models: TLG.fst, config.yaml ", false, "damo/speech_ngram_lm_zh-cn-ai-wesp-fst", "string");
TCLAP::ValueArg<std::string> lm_revision(
"", "lm-revision", "LM model revision", false, "v1.0.1", "string");
TCLAP::ValueArg<std::string> hotword("", HOTWORD,
@@ -436,6 +440,8 @@
server server_; // server for websocket
wss_server wss_server_;
+ server* server = nullptr;
+ wss_server* wss_server = nullptr;
if (is_ssl) {
LOG(INFO)<< "SSL is opened!";
wss_server_.init_asio(&io_server); // init asio
@@ -444,11 +450,7 @@
// list on port for accept
wss_server_.listen(asio::ip::address::from_string(s_listen_ip), s_port);
- WebSocketServer websocket_srv(
- io_decoder, is_ssl, nullptr, &wss_server_, s_certfile,
- s_keyfile); // websocket server for asr engine
- websocket_srv.initAsr(model_path, s_model_thread_num); // init asr model
-
+ wss_server = &wss_server_;
} else {
LOG(INFO)<< "SSL is closed!";
server_.init_asio(&io_server); // init asio
@@ -457,12 +459,15 @@
// list on port for accept
server_.listen(asio::ip::address::from_string(s_listen_ip), s_port);
- WebSocketServer websocket_srv(
- io_decoder, is_ssl, &server_, nullptr, s_certfile,
- s_keyfile); // websocket server for asr engine
- websocket_srv.initAsr(model_path, s_model_thread_num); // init asr model
+ server = &server_;
}
+
+ WebSocketServer websocket_srv(
+ io_decoder, is_ssl, server, wss_server, s_certfile,
+ s_keyfile); // websocket server for asr engine
+ websocket_srv.initAsr(model_path, s_model_thread_num); // init asr model
+
LOG(INFO) << "decoder-thread-num: " << s_decoder_thread_num;
LOG(INFO) << "io-thread-num: " << s_io_thread_num;
LOG(INFO) << "model-thread-num: " << s_model_thread_num;
--
Gitblit v1.9.1