zhaomingwork
2023-08-01 65c18785016c099f40ff626c2c6a7dac91c3426f
add is_final for python_ws_srv (#794)

2个文件已修改
10 ■■■■ 已修改文件
funasr/runtime/python/websocket/funasr_wss_client.py 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
funasr/runtime/python/websocket/funasr_wss_server.py 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
funasr/runtime/python/websocket/funasr_wss_client.py
@@ -222,7 +222,11 @@
                # 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 = True
            else:
                if meg["mode"] == "2pass-online":
                    text_print_2pass_online += "{}".format(text)
funasr/runtime/python/websocket/funasr_wss_server.py
@@ -241,7 +241,7 @@
                    # 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 @@
            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: