From 3d9f094e9652d4b84894c6fd4eae39a4a753b0f0 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期二, 16 五月 2023 23:48:00 +0800
Subject: [PATCH] train

---
 funasr/runtime/websocket/websocketsrv.h |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/funasr/runtime/websocket/websocketsrv.h b/funasr/runtime/websocket/websocketsrv.h
index 2d0c7bd..82d717e 100644
--- a/funasr/runtime/websocket/websocketsrv.h
+++ b/funasr/runtime/websocket/websocketsrv.h
@@ -30,7 +30,7 @@
 
 #include "asio.hpp"
 #include "com-define.h"
-#include "libfunasrapi.h"
+#include "funasrruntime.h"
 #include "nlohmann/json.hpp"
 #include "tclap/CmdLine.h"
 typedef websocketpp::server<websocketpp::config::asio> server;
@@ -45,6 +45,11 @@
   std::string msg;
   float snippet_time;
 } FUNASR_RECOG_RESULT;
+
+typedef struct {
+  nlohmann::json msg;
+  std::shared_ptr<std::vector<char>> samples;
+} FUNASR_MESSAGE;
 
 class WebSocketServer {
  public:
@@ -67,7 +72,7 @@
     server_->clear_access_channels(websocketpp::log::alevel::all);
   }
   void do_decoder(const std::vector<char>& buffer,
-                  websocketpp::connection_hdl& hdl);
+                  websocketpp::connection_hdl& hdl, const nlohmann::json& msg);
 
   void initAsr(std::map<std::string, std::string>& model_path, int thread_num);
   void on_message(websocketpp::connection_hdl hdl, message_ptr msg);
@@ -84,9 +89,10 @@
 
   // use map to keep the received samples data from one connection in offline
   // engine. if for online engline, a data struct is needed(TODO)
-  std::map<websocketpp::connection_hdl, std::shared_ptr<std::vector<char>>,
+
+  std::map<websocketpp::connection_hdl, std::shared_ptr<FUNASR_MESSAGE>,
            std::owner_less<websocketpp::connection_hdl>>
-      sample_map;
+      data_map;
   websocketpp::lib::mutex m_lock;  // mutex for sample_map
 };
 

--
Gitblit v1.9.1