From 63bcaf7093c986e0c33b14212fca3705c0877864 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期五, 31 三月 2023 17:28:00 +0800
Subject: [PATCH] export

---
 funasr/runtime/python/websocket/ASR_server.py |    4 +++-
 funasr/runtime/python/websocket/ASR_client.py |    5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/funasr/runtime/python/websocket/ASR_client.py b/funasr/runtime/python/websocket/ASR_client.py
index fe67981..d1fb93a 100644
--- a/funasr/runtime/python/websocket/ASR_client.py
+++ b/funasr/runtime/python/websocket/ASR_client.py
@@ -6,6 +6,7 @@
 from queue import Queue
 # import threading
 import argparse
+import json
 
 parser = argparse.ArgumentParser()
 parser.add_argument("--host",
@@ -78,7 +79,9 @@
     global websocket
     while True:
         try:
-            print(await websocket.recv())
+            meg = await websocket.recv()
+            meg = json.loads(meg)
+            print(meg)
         except Exception as e:
             print("Exception:", e)          
         
diff --git a/funasr/runtime/python/websocket/ASR_server.py b/funasr/runtime/python/websocket/ASR_server.py
index 827df7b..c717e71 100644
--- a/funasr/runtime/python/websocket/ASR_server.py
+++ b/funasr/runtime/python/websocket/ASR_server.py
@@ -4,6 +4,7 @@
 from queue import Queue
 import threading
 import argparse
+import json
 
 from modelscope.pipelines import pipeline
 from modelscope.utils.constant import Tasks
@@ -157,7 +158,8 @@
                         rec_result = inference_pipeline_punc(text_in=rec_result['text'], param_dict=websocket.param_dict_punc)
                     # print(rec_result)
                     if "text" in rec_result:
-                        websocket.send_msg.put(rec_result["text"]) # 瀛樺叆鍙戦�侀槦鍒�  鐩存帴璋冪敤send鍙戦�佷笉浜�
+                        message = json.dumps({"mode": "offline", "text": rec_result["text"]})
+                        websocket.send_msg.put(message)  # 瀛樺叆鍙戦�侀槦鍒�  鐩存帴璋冪敤send鍙戦�佷笉浜�
                
             time.sleep(0.1)
 

--
Gitblit v1.9.1