Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
Modified cpp ws server for centos (#610)
zhaomingwork72cdfe65e386
diff --git a/funasr/runtime/websocket/readme.md b/funasr/runtime/websocket/readme.mdindex d2a54e986..99255c8bb 100644--- a/funasr/runtime/websocket/readme.md+++ b/funasr/runtime/websocket/readme.md@@ -36,8 +36,11 @@ sudo apt-get install libopenblas-dev #ubunturequired openssl lib```shell-#install openssl lib first+#install openssl lib for ubuntuapt-get install libssl-dev+#install openssl lib for centos+yum install openssl-devel+git clone https://github.com/alibaba-damo-academy/FunASR.git && cd funasr/runtime/websocketmkdir build && cd builddiff --git a/funasr/runtime/websocket/websocketmain.cpp b/funasr/runtime/websocket/websocketmain.cppindex 306c3f0dc..fabf6d81f 100644--- a/funasr/runtime/websocket/websocketmain.cpp+++ b/funasr/runtime/websocket/websocketmain.cpp@@ -102,6 +102,7 @@ int main(int argc, char* argv[]) {int s_model_thread_num = model_thread_num.getValue();asio::io_context io_decoder; // context for decoding+ asio::io_context io_server; // context for serverstd::vector<std::thread> decoder_threads;@@ -115,7 +116,8 @@ int main(int argc, char* argv[]) {auto conn_guard = asio::make_work_guard(io_decoder); // make sure threads can wait in the queue-+ auto server_guard = asio::make_work_guard(+ io_server); // make sure threads can wait in the queue// create threads poolfor (int32_t i = 0; i < s_decoder_thread_num; ++i) {decoder_threads.emplace_back([&io_decoder]() { io_decoder.run(); });@@ -124,7 +126,7 @@ int main(int argc, char* argv[]) {server server_; // server for websocketwss_server wss_server_;if (is_ssl) {- wss_server_.init_asio(); // init asio+ wss_server_.init_asio(&io_server); // init asiowss_server_.set_reuse_addr(true); // reuse address as we create multiple threads@@ -136,7 +138,7 @@ int main(int argc, char* argv[]) {websocket_srv.initAsr(model_path, s_model_thread_num); // init asr model} else {- server_.init_asio(); // init asio+ server_.init_asio(&io_server); // init asioserver_.set_reuse_addr(true); // reuse address as we create multiple threads@@ -152,29 +154,14 @@ int main(int argc, char* argv[]) {<< std::endl;// Start the ASIO network io_service run loop- if (s_io_thread_num == 1) {- if (is_ssl) {- wss_server_.run();- } else {- server_.run();- }- } else {- typedef websocketpp::lib::shared_ptr<websocketpp::lib::thread> thread_ptr;- std::vector<thread_ptr> ts;- // create threads for io network- for (size_t i = 0; i < s_io_thread_num; i++) {- if (is_ssl) {- ts.push_back(websocketpp::lib::make_shared<websocketpp::lib::thread>(- &wss_server::run, &wss_server_));- } else {- ts.push_back(websocketpp::lib::make_shared<websocketpp::lib::thread>(- &server::run, &server_));- }- }- // wait for theads- for (size_t i = 0; i < s_io_thread_num; i++) {- ts[i]->join();- }+ std::vector<std::thread> ts;+ // create threads for io network+ for (size_t i = 0; i < s_io_thread_num; i++) {+ ts.emplace_back([&io_server]() { io_server.run(); });+ }+ // wait for theads+ for (size_t i = 0; i < s_io_thread_num; i++) {+ ts[i].join();}// wait for theads