zhifu gao
2023-05-08 7557fa87a8043867e39f4920b38d6163d54095ef
funasr/runtime/python/websocket/ws_server_offline.py
@@ -78,6 +78,7 @@
                is_speaking = message["is_speaking"]
                websocket.param_dict_vad["is_final"] = not is_speaking
                websocket.wav_name = message.get("wav_name", "demo")
                if speech_start:
                    frames_asr.append(audio)
                speech_start_i, speech_end_i = await async_vad(websocket, audio)
@@ -136,12 +137,13 @@
                    rec_result = inference_pipeline_punc(text_in=rec_result['text'],
                                                         param_dict=websocket.param_dict_punc)
                    # print(rec_result)
                    message = json.dumps({"mode": "offline", "text": [rec_result["text"]]})
                message = json.dumps({"mode": "offline", "text": [rec_result["text"]], "wav_name": websocket.wav_name})
                    await websocket.send(message)
                    
 
start_server = websockets.serve(ws_serve, args.host, args.port, subprotocols=["binary"], ping_interval=None)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()