Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
add is_final for python_ws_srv (#794)
zhaomingwork65c18785016c
diff --git a/funasr/runtime/python/websocket/funasr_wss_client.py b/funasr/runtime/python/websocket/funasr_wss_client.pyindex 264014f05..5830db4c3 100644--- a/funasr/runtime/python/websocket/funasr_wss_client.py+++ b/funasr/runtime/python/websocket/funasr_wss_client.py@@ -222,7 +222,11 @@ async def message(id):# text_print = text_print[-args.words_max_print:]# os.system('clear')print("\rpid" + str(id) + ": " + wav_name + ": " + text_print)- offline_msg_done = True+ if ("is_final" in meg and meg["is_final"]==False):+ offline_msg_done = True++ if not "is_final" in meg:+ offline_msg_done = Trueelse:if meg["mode"] == "2pass-online":text_print_2pass_online += "{}".format(text)diff --git a/funasr/runtime/python/websocket/funasr_wss_server.py b/funasr/runtime/python/websocket/funasr_wss_server.pyindex 2aff9ba0e..57f75847c 100644--- a/funasr/runtime/python/websocket/funasr_wss_server.py+++ b/funasr/runtime/python/websocket/funasr_wss_server.py@@ -241,7 +241,7 @@ async def async_asr(websocket, audio_in):# print("offline", rec_result)if 'text' in rec_result: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})+ message = json.dumps({"mode": mode, "text": rec_result["text"], "wav_name": websocket.wav_name,"is_final":websocket.is_speaking})await websocket.send(message)@@ -258,7 +258,7 @@ async def async_asr_online(websocket, audio_in):if rec_result["text"] != "sil" and rec_result["text"] != "waiting_for_more_voice":# print("online", rec_result)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})+ 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: