| | |
| | | from queue import Queue |
| | | import threading |
| | | import argparse |
| | | import json |
| | | |
| | | from modelscope.pipelines import pipeline |
| | | from modelscope.utils.constant import Tasks |
| | |
| | | |
| | | |
| | | def asr(websocket): # ASR推理 |
| | | global inference_pipeline2 |
| | | global inference_pipeline_asr, inference_pipeline_punc |
| | | # global param_dict_punc |
| | | global websocket_users |
| | | while websocket in websocket_users: |
| | |
| | | rec_result = inference_pipeline_punc(text_in=rec_result['text'], param_dict=websocket.param_dict_punc) |
| | | # print(rec_result) |
| | | if "text" in rec_result: |
| | | websocket.send_msg.put(rec_result["text"]) # 存入发送队列 直接调用send发送不了 |
| | | message = json.dumps({"mode": "offline", "text": rec_result["text"]}) |
| | | websocket.send_msg.put(message) # 存入发送队列 直接调用send发送不了 |
| | | |
| | | time.sleep(0.1) |
| | | |
| | | def vad(data, websocket): # VAD推理 |
| | | global vad_pipline, param_dict_vad |
| | | global inference_pipeline_vad |
| | | #print(type(data)) |
| | | # print(param_dict_vad) |
| | | segments_result = inference_pipeline_vad(audio_in=data, param_dict=websocket.param_dict_vad) |