From d20c030e5b75306dd67e8fe9924d5d94eac1bf30 Mon Sep 17 00:00:00 2001 From: wusong <63332221+wusong1128@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:11:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3python=20ws=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E9=92=88=E5=AF=B9=E5=B0=BE=E9=83=A8=E9=9D=9E=E4=BA=BA=E5=A3=B0?= =?UTF-8?q?=E5=BD=95=E9=9F=B3=E6=97=A0=E7=BB=93=E6=9D=9F=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=9A=84=E9=97=AE=E9=A2=98=20(#2102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime/python/websocket/funasr_wss_server.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/runtime/python/websocket/funasr_wss_server.py b/runtime/python/websocket/funasr_wss_server.py index 1ff5856b5..9de120e43 100644 --- a/runtime/python/websocket/funasr_wss_server.py +++ b/runtime/python/websocket/funasr_wss_server.py @@ -187,7 +187,7 @@ async def ws_serve(websocket, path): websocket.status_dict_vad["chunk_size"] = int( websocket.status_dict_asr_online["chunk_size"][1] * 60 / websocket.chunk_interval ) - if len(frames_asr_online) > 0 or len(frames_asr) > 0 or not isinstance(message, str): + if len(frames_asr_online) > 0 or len(frames_asr) >= 0 or not isinstance(message, str): if not isinstance(message, str): frames.append(message) duration_ms = len(message) // 32 @@ -291,6 +291,17 @@ async def async_asr(websocket, audio_in): ) await websocket.send(message) + else: + mode = "2pass-offline" if "2pass" in websocket.mode else websocket.mode + message = json.dumps( + { + "mode": mode, + "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: