mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
add is_final for python_ws_srv (#794)
This commit is contained in:
parent
248a9979c3
commit
65c1878501
@ -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 = True
|
||||
else:
|
||||
if meg["mode"] == "2pass-online":
|
||||
text_print_2pass_online += "{}".format(text)
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user