From f2eb55ded73a6ec84a2d3c466345701b08794650 Mon Sep 17 00:00:00 2001 From: "shixian.shi" Date: Thu, 10 Aug 2023 13:43:07 +0800 Subject: [PATCH 1/2] update --- funasr/models/e2e_asr_contextual_paraformer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/funasr/models/e2e_asr_contextual_paraformer.py b/funasr/models/e2e_asr_contextual_paraformer.py index d27fd8db1..64e0f8d03 100644 --- a/funasr/models/e2e_asr_contextual_paraformer.py +++ b/funasr/models/e2e_asr_contextual_paraformer.py @@ -350,6 +350,7 @@ class NeatContextualParaformer(Paraformer): else: hw_embed = self.bias_embed(hw_list_pad) hw_embed, (h_n, _) = self.bias_encoder(hw_embed) + hw_embed = h_n.repeat(encoder_out.shape[0], 1, 1) else: hw_lengths = [len(i) for i in hw_list] hw_list_pad = pad_list([torch.Tensor(i).long() for i in hw_list], 0).to(encoder_out.device) From c8465832cdc8eeb4a22c72af85c71f2d3b7c0e47 Mon Sep 17 00:00:00 2001 From: zhaomingwork <61895407+zhaomingwork@users.noreply.github.com> Date: Thu, 10 Aug 2023 15:03:16 +0800 Subject: [PATCH 2/2] for cpp ws srv long wav core dump (#829) --- funasr/runtime/websocket/websocket-server-2pass.cpp | 13 +++++++++---- funasr/runtime/websocket/websocket-server-2pass.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/funasr/runtime/websocket/websocket-server-2pass.cpp b/funasr/runtime/websocket/websocket-server-2pass.cpp index 75312a332..b41c5c9c1 100644 --- a/funasr/runtime/websocket/websocket-server-2pass.cpp +++ b/funasr/runtime/websocket/websocket-server-2pass.cpp @@ -81,6 +81,10 @@ void WebSocketServer::do_decoder( FUNASR_HANDLE& tpass_online_handle) { // lock for each connection scoped_lock guard(thread_lock); + if(!tpass_online_handle){ + LOG(INFO) << "tpass_online_handle is free, return"; + return; + } FUNASR_RESULT Result = nullptr; int asr_mode_ = 2; if (msg.contains("mode")) { @@ -180,7 +184,7 @@ void WebSocketServer::on_open(websocketpp::connection_hdl hdl) { std::make_shared(); // put a new data vector for new // connection data_msg->samples = std::make_shared>(); - data_msg->thread_lock = new websocketpp::lib::mutex(); + data_msg->thread_lock = std::make_shared(); data_msg->msg = nlohmann::json::parse("{}"); data_msg->msg["wav_format"] = "pcm"; @@ -199,7 +203,7 @@ void remove_hdl( websocketpp::connection_hdl hdl, std::map, std::owner_less>& data_map) { - // return; + std::shared_ptr data_msg = nullptr; auto it_data = data_map.find(hdl); if (it_data != data_map.end()) { @@ -215,8 +219,9 @@ void remove_hdl( FunTpassOnlineUninit(data_msg->tpass_online_handle); data_msg->tpass_online_handle = nullptr; } + + guard_decoder.unlock(); - delete data_msg->thread_lock; data_map.erase(hdl); // remove data vector when connection is closed } @@ -270,7 +275,7 @@ void WebSocketServer::on_message(websocketpp::connection_hdl hdl, std::shared_ptr> sample_data_p = msg_data->samples; std::shared_ptr>> punc_cache_p = msg_data->punc_cache; - websocketpp::lib::mutex* thread_lock_p = msg_data->thread_lock; + std::shared_ptr thread_lock_p = msg_data->thread_lock; lock.unlock(); diff --git a/funasr/runtime/websocket/websocket-server-2pass.h b/funasr/runtime/websocket/websocket-server-2pass.h index d483283a2..a705cfbcb 100644 --- a/funasr/runtime/websocket/websocket-server-2pass.h +++ b/funasr/runtime/websocket/websocket-server-2pass.h @@ -54,7 +54,7 @@ typedef struct { nlohmann::json msg; std::shared_ptr> samples; std::shared_ptr>> punc_cache; - websocketpp::lib::mutex* thread_lock; // lock for each connection + std::shared_ptr thread_lock; // lock for each connection FUNASR_HANDLE tpass_online_handle=NULL; std::string online_res = ""; std::string tpass_res = "";