From bf6947bcb2e135d2fab5dc4a66654ebcfef24b85 Mon Sep 17 00:00:00 2001
From: zhaomingwork <61895407+zhaomingwork@users.noreply.github.com>
Date: 星期二, 29 八月 2023 10:45:34 +0800
Subject: [PATCH] for h5 root url redirect to index (#898)

---
 funasr/runtime/websocket/websocket-server.cpp |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/funasr/runtime/websocket/websocket-server.cpp b/funasr/runtime/websocket/websocket-server.cpp
index 952acad..f9febbd 100644
--- a/funasr/runtime/websocket/websocket-server.cpp
+++ b/funasr/runtime/websocket/websocket-server.cpp
@@ -83,6 +83,7 @@
       nlohmann::json jsonresult;        // result json
       jsonresult["text"] = asr_result;  // put result in 'text'
       jsonresult["mode"] = "offline";
+	    jsonresult["is_final"] = false;
       if(stamp_res != ""){
         jsonresult["timestamp"] = stamp_res;
       }
@@ -98,6 +99,23 @@
       }
 
       LOG(INFO) << "buffer.size=" << buffer.size() << ",result json=" << jsonresult.dump();
+    }else{
+      LOG(INFO) << "Sent empty meg";
+      websocketpp::lib::error_code ec;
+      nlohmann::json jsonresult;        // result json
+      jsonresult["text"] = "";  // put result in 'text'
+      jsonresult["mode"] = "offline";
+	    jsonresult["is_final"] = false;
+      jsonresult["wav_name"] = wav_name;
+
+      // send the json to client
+      if (is_ssl) {
+        wss_server_->send(hdl, jsonresult.dump(),
+                          websocketpp::frame::opcode::text, ec);
+      } else {
+        server_->send(hdl, jsonresult.dump(), websocketpp::frame::opcode::text,
+                      ec);
+      }
     }
 
   } catch (std::exception const& e) {

--
Gitblit v1.9.1