From 1d7bbbffb6a024a33859b48a7a656d0455dc0be1 Mon Sep 17 00:00:00 2001
From: zhifu gao <zhifu.gzf@alibaba-inc.com>
Date: 星期一, 16 十月 2023 11:47:59 +0800
Subject: [PATCH] Update README.md
---
funasr/runtime/python/websocket/funasr_wss_server.py | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/funasr/runtime/python/websocket/funasr_wss_server.py b/funasr/runtime/python/websocket/funasr_wss_server.py
index fd039ae..b74f225 100644
--- a/funasr/runtime/python/websocket/funasr_wss_server.py
+++ b/funasr/runtime/python/websocket/funasr_wss_server.py
@@ -10,7 +10,6 @@
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.utils.logger import get_logger
-from funasr.runtime.python.onnxruntime.funasr_onnx.utils.frontend import load_bytes
tracemalloc.start()
@@ -104,8 +103,8 @@
model=args.asr_model_online,
ngpu=args.ngpu,
ncpu=args.ncpu,
- model_revision='v1.0.4',
- update_model='v1.0.4',
+ model_revision='v1.0.7',
+ update_model='v1.0.7',
mode='paraformer_streaming')
print("model loaded! only support one client at the same time now!!!!")
@@ -160,6 +159,10 @@
websocket.wav_name = messagejson.get("wav_name")
if "chunk_size" in messagejson:
websocket.param_dict_asr_online["chunk_size"] = messagejson["chunk_size"]
+ if "encoder_chunk_look_back" in messagejson:
+ websocket.param_dict_asr_online["encoder_chunk_look_back"] = messagejson["encoder_chunk_look_back"]
+ if "decoder_chunk_look_back" in messagejson:
+ websocket.param_dict_asr_online["decoder_chunk_look_back"] = messagejson["decoder_chunk_look_back"]
if "mode" in messagejson:
websocket.mode = messagejson["mode"]
if len(frames_asr_online) > 0 or len(frames_asr) > 0 or not isinstance(message, str):
@@ -233,8 +236,6 @@
async def async_asr(websocket, audio_in):
if len(audio_in) > 0:
# print(len(audio_in))
- audio_in = load_bytes(audio_in)
-
rec_result = inference_pipeline_asr(audio_in=audio_in,
param_dict=websocket.param_dict_asr)
# print(rec_result)
@@ -243,13 +244,13 @@
param_dict=websocket.param_dict_punc)
# print("offline", rec_result)
if 'text' in rec_result:
- message = json.dumps({"mode": "2pass-offline", "text": rec_result["text"], "wav_name": websocket.wav_name})
+ mode = "2pass-offline" if "2pass" in websocket.mode else websocket.mode
+ message = json.dumps({"mode": mode, "text": rec_result["text"], "wav_name": websocket.wav_name,"is_final":websocket.is_speaking})
await websocket.send(message)
async def async_asr_online(websocket, audio_in):
if len(audio_in) > 0:
- audio_in = load_bytes(audio_in)
# print(websocket.param_dict_asr_online.get("is_final", False))
rec_result = inference_pipeline_asr_online(audio_in=audio_in,
param_dict=websocket.param_dict_asr_online)
@@ -260,7 +261,8 @@
if "text" in rec_result:
if rec_result["text"] != "sil" and rec_result["text"] != "waiting_for_more_voice":
# print("online", rec_result)
- message = json.dumps({"mode": "2pass-online", "text": rec_result["text"], "wav_name": websocket.wav_name})
+ mode = "2pass-online" if "2pass" in websocket.mode else websocket.mode
+ message = json.dumps({"mode": mode, "text": rec_result["text"], "wav_name": websocket.wav_name,"is_final":websocket.is_speaking})
await websocket.send(message)
if len(args.certfile)>0:
--
Gitblit v1.9.1