From e08be2e41ca35031e1ea7649c475f767f50e402b Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期三, 09 八月 2023 19:48:46 +0800
Subject: [PATCH] docs
---
funasr/runtime/websocket/websocket-server-2pass.cpp | 21 +++++++--------------
1 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/funasr/runtime/websocket/websocket-server-2pass.cpp b/funasr/runtime/websocket/websocket-server-2pass.cpp
index 8833b0b..b85ce9a 100644
--- a/funasr/runtime/websocket/websocket-server-2pass.cpp
+++ b/funasr/runtime/websocket/websocket-server-2pass.cpp
@@ -53,22 +53,19 @@
return ctx;
}
-nlohmann::json handle_result(FUNASR_RESULT result, std::string& online_res,
- std::string& tpass_res, nlohmann::json msg) {
+nlohmann::json handle_result(FUNASR_RESULT result, nlohmann::json msg) {
websocketpp::lib::error_code ec;
nlohmann::json jsonresult;
jsonresult["text"]="";
std::string tmp_online_msg = FunASRGetResult(result, 0);
- online_res += tmp_online_msg;
if (tmp_online_msg != "") {
LOG(INFO) << "online_res :" << tmp_online_msg;
jsonresult["text"] = tmp_online_msg;
jsonresult["mode"] = "2pass-online";
}
std::string tmp_tpass_msg = FunASRGetTpassResult(result, 0);
- tpass_res += tmp_tpass_msg;
if (tmp_tpass_msg != "") {
LOG(INFO) << "offline results : " << tmp_tpass_msg;
jsonresult["text"] = tmp_tpass_msg;
@@ -86,8 +83,7 @@
std::vector<char>& buffer, websocketpp::connection_hdl& hdl,
nlohmann::json& msg, std::vector<std::vector<std::string>>& punc_cache,
websocketpp::lib::mutex& thread_lock, bool& is_final,
- FUNASR_HANDLE& tpass_online_handle, std::string& online_res,
- std::string& tpass_res) {
+ FUNASR_HANDLE& tpass_online_handle) {
// lock for each connection
scoped_lock guard(thread_lock);
@@ -127,7 +123,7 @@
if (Result) {
websocketpp::lib::error_code ec;
nlohmann::json jsonresult =
- handle_result(Result, online_res, tpass_res, msg["wav_name"]);
+ handle_result(Result, msg);
jsonresult["is_final"] = false;
if(jsonresult["text"] != "") {
if (is_ssl) {
@@ -158,7 +154,7 @@
if (Result) {
websocketpp::lib::error_code ec;
nlohmann::json jsonresult =
- handle_result(Result, online_res, tpass_res, msg["wav_name"]);
+ handle_result(Result, msg);
jsonresult["is_final"] = true;
if (is_ssl) {
wss_server_->send(hdl, jsonresult.dump(),
@@ -212,6 +208,7 @@
return;
}
scoped_lock guard_decoder(*(data_msg->thread_lock)); //wait for do_decoder finished and avoid access freed tpass_online_handle
+ LOG(INFO) << "----------------FunTpassOnlineUninit----------------------";
FunTpassOnlineUninit(data_msg->tpass_online_handle);
data_map.erase(hdl); // remove data vector when connection is closed
LOG(INFO) << "on_close, active connections: "<< data_map.size();
@@ -306,9 +303,7 @@
std::move(*(sample_data_p.get())), std::move(hdl),
std::ref(msg_data->msg), std::ref(*(punc_cache_p.get())),
std::ref(*thread_lock_p), std::move(true),
- std::ref(msg_data->tpass_online_handle),
- std::ref(msg_data->online_res),
- std::ref(msg_data->tpass_res)));
+ std::ref(msg_data->tpass_online_handle)));
}
break;
}
@@ -338,9 +333,7 @@
std::ref(msg_data->msg),
std::ref(*(punc_cache_p.get())),
std::ref(*thread_lock_p), std::move(false),
- std::ref(msg_data->tpass_online_handle),
- std::ref(msg_data->online_res),
- std::ref(msg_data->tpass_res)));
+ std::ref(msg_data->tpass_online_handle)));
}
} else {
sample_data_p->insert(sample_data_p->end(), pcm_data,
--
Gitblit v1.9.1