From f9896b7b72314f2b4e1054b5ed8214a3086f50f0 Mon Sep 17 00:00:00 2001
From: zhifu gao <zhifu.gzf@alibaba-inc.com>
Date: 星期日, 07 五月 2023 23:04:01 +0800
Subject: [PATCH] Merge pull request #467 from alibaba-damo-academy/dev_websocket_offline
---
funasr/runtime/python/websocket/ws_server_online.py | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/funasr/runtime/python/websocket/ws_server_online.py b/funasr/runtime/python/websocket/ws_server_online.py
index 4e6c38e..6ea8f39 100644
--- a/funasr/runtime/python/websocket/ws_server_online.py
+++ b/funasr/runtime/python/websocket/ws_server_online.py
@@ -12,7 +12,7 @@
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.utils.logger import get_logger
-from funasr_onnx.utils.frontend import load_bytes
+from funasr.runtime.python.onnxruntime.funasr_onnx.utils.frontend import load_bytes
tracemalloc.start()
@@ -28,6 +28,8 @@
inference_pipeline_asr_online = pipeline(
task=Tasks.auto_speech_recognition,
model=args.asr_model_online,
+ ngpu=args.ngpu,
+ ncpu=args.ncpu,
model_revision='v1.0.4')
print("model loaded")
@@ -63,14 +65,14 @@
except websockets.ConnectionClosed:
- print("ConnectionClosed...", websocket_users) # 閾炬帴鏂紑
+ print("ConnectionClosed...", websocket_users)
websocket_users.remove(websocket)
except websockets.InvalidState:
- print("InvalidState...") # 鏃犳晥鐘舵��
+ print("InvalidState...")
except Exception as e:
print("Exception:", e)
-async def async_asr_online(websocket,audio_in): # ASR鎺ㄧ悊
+async def async_asr_online(websocket,audio_in):
if len(audio_in) > 0:
audio_in = load_bytes(audio_in)
rec_result = inference_pipeline_asr_online(audio_in=audio_in,
@@ -84,7 +86,6 @@
message = json.dumps({"mode": "online", "text": rec_result["text"]})
await websocket.send(message)
-
start_server = websockets.serve(ws_serve, args.host, args.port, subprotocols=["binary"], ping_interval=None)
--
Gitblit v1.9.1