From 6eb0dfced4ab87b3fd831affd806aad84d37dc1f Mon Sep 17 00:00:00 2001
From: Yabin Li <wucong.lyb@alibaba-inc.com>
Date: 星期一, 23 十月 2023 10:48:54 +0800
Subject: [PATCH] Dev server hotwords (#1033)
---
funasr/runtime/websocket/bin/websocket-server.cpp | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/funasr/runtime/websocket/bin/websocket-server.cpp b/funasr/runtime/websocket/bin/websocket-server.cpp
index da1ffa5..6e1c211 100644
--- a/funasr/runtime/websocket/bin/websocket-server.cpp
+++ b/funasr/runtime/websocket/bin/websocket-server.cpp
@@ -16,6 +16,8 @@
#include <utility>
#include <vector>
+extern std::string hotwords;
+
context_ptr WebSocketServer::on_tls_init(tls_mode mode,
websocketpp::connection_hdl hdl,
std::string& s_certfile,
@@ -266,17 +268,26 @@
msg_data->msg["hotwords"] = jsonresult["hotwords"];
if (!msg_data->msg["hotwords"].empty()) {
std::string hw = msg_data->msg["hotwords"];
- LOG(INFO)<<"hotwords: " << hw;
- std::vector<std::vector<float>> new_hotwords_embedding= CompileHotwordEmbedding(asr_hanlde, hw);
+ hw = hw + " " + hotwords;
+ LOG(INFO) << "hotwords: " << hw;
+ std::vector<std::vector<float>> new_hotwords_embedding = CompileHotwordEmbedding(asr_hanlde, hw);
msg_data->hotwords_embedding =
std::make_shared<std::vector<std::vector<float>>>(new_hotwords_embedding);
}
- }else{
+ } else {
+ if (hotwords.empty()) {
std::string hw = "";
LOG(INFO)<<"hotwords: " << hw;
std::vector<std::vector<float>> new_hotwords_embedding= CompileHotwordEmbedding(asr_hanlde, hw);
msg_data->hotwords_embedding =
std::make_shared<std::vector<std::vector<float>>>(new_hotwords_embedding);
+ }else {
+ std::string hw = hotwords;
+ LOG(INFO) << "hotwords: " << hw;
+ std::vector<std::vector<float>> new_hotwords_embedding= CompileHotwordEmbedding(asr_hanlde, hw);
+ msg_data->hotwords_embedding =
+ std::make_shared<std::vector<std::vector<float>>>(new_hotwords_embedding);
+ }
}
}
if (jsonresult.contains("audio_fs")) {
--
Gitblit v1.9.1