Skip to content

Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.

Merge pull request #585 from alibaba-damo-academy/dev_lhn3

hnluo6ad154b79ac6
diff --cc funasr/runtime/python/websocket/wss_srv_asr.py
index 661e174de,76cbf77e9..948619b95
--- a/funasr/runtime/python/websocket/wss_srv_asr.py
+++ b/funasr/runtime/python/websocket/wss_srv_asr.py
@@@ -59,29 -59,11 +59,29 @@@ inference_pipeline_asr_online = pipelin
ngpu=args.ngpu,
ncpu=args.ncpu,
model_revision='v1.0.4',
- update_model='v1.0.4'
+ update_model='v1.0.4',
mode='paraformer_streaming')
-print("model loaded")
+print("model loaded! only support one client at the same time now!!!!")
+async def ws_reset(websocket):
+ print("ws reset now, total num is ",len(websocket_users))
+ websocket.param_dict_asr_online = {"cache": dict()}
+ websocket.param_dict_vad = {'in_cache': dict(), "is_final": True}
+ websocket.param_dict_asr_online["is_final"]=True
+ audio_in=b''.join(np.zeros(int(16000),dtype=np.int16))
+ inference_pipeline_vad(audio_in=audio_in, param_dict=websocket.param_dict_vad)
+ inference_pipeline_asr_online(audio_in=audio_in, param_dict=websocket.param_dict_asr_online)
+ await websocket.close()
+
+
+async def clear_websocket():
+ for websocket in websocket_users:
+ await ws_reset(websocket)
+ websocket_users.clear()
+
+
+
async def ws_serve(websocket, path):
frames = []
frames_asr = []