From 32905d8cdedd53dad26680b0bd41397aaf0e51ae Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期五, 05 一月 2024 11:52:48 +0800
Subject: [PATCH] funasr1.0
---
runtime/websocket/bin/websocket-server-2pass.cpp | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/runtime/websocket/bin/websocket-server-2pass.cpp b/runtime/websocket/bin/websocket-server-2pass.cpp
index bd0c590..5cfd461 100644
--- a/runtime/websocket/bin/websocket-server-2pass.cpp
+++ b/runtime/websocket/bin/websocket-server-2pass.cpp
@@ -98,8 +98,8 @@
std::string wav_format,
FUNASR_HANDLE& tpass_online_handle) {
// lock for each connection
- scoped_lock guard(thread_lock);
if(!tpass_online_handle){
+ scoped_lock guard(thread_lock);
LOG(INFO) << "tpass_online_handle is free, return";
msg["access_num"]=(int)msg["access_num"]-1;
return;
@@ -128,10 +128,12 @@
hotwords_embedding, itn);
} else {
+ scoped_lock guard(thread_lock);
msg["access_num"]=(int)msg["access_num"]-1;
return;
}
} catch (std::exception const& e) {
+ scoped_lock guard(thread_lock);
LOG(ERROR) << e.what();
msg["access_num"]=(int)msg["access_num"]-1;
return;
@@ -162,10 +164,12 @@
wav_format, (ASR_TYPE)asr_mode_,
hotwords_embedding, itn);
} else {
+ scoped_lock guard(thread_lock);
msg["access_num"]=(int)msg["access_num"]-1;
return;
}
} catch (std::exception const& e) {
+ scoped_lock guard(thread_lock);
LOG(ERROR) << e.what();
msg["access_num"]=(int)msg["access_num"]-1;
return;
@@ -209,6 +213,7 @@
} catch (std::exception const& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
+ scoped_lock guard(thread_lock);
msg["access_num"]=(int)msg["access_num"]-1;
}
@@ -452,7 +457,9 @@
LOG(INFO) << "jsonresult=" << jsonresult
<< ", msg_data->msg=" << msg_data->msg;
if ((jsonresult["is_speaking"] == false ||
- jsonresult["is_finished"] == true) && msg_data->msg["is_eof"] != true) {
+ jsonresult["is_finished"] == true) &&
+ msg_data->msg["is_eof"] != true &&
+ msg_data->hotwords_embedding != NULL) {
LOG(INFO) << "client done";
// if it is in final message, post the sample_data to decode
@@ -503,9 +510,9 @@
try{
// post to decode
- if (msg_data->msg["is_eof"] != true) {
+ if (msg_data->msg["is_eof"] != true && msg_data->hotwords_embedding != NULL) {
std::vector<std::vector<float>> hotwords_embedding_(*(msg_data->hotwords_embedding));
- msg_data->strand_->post(
+ msg_data->strand_->post(
std::bind(&WebSocketServer::do_decoder, this,
std::move(subvector), std::move(hdl),
std::ref(msg_data->msg),
--
Gitblit v1.9.1