游雁
2023-03-31 63bcaf7093c986e0c33b14212fca3705c0877864
export
2个文件已修改
9 ■■■■ 已修改文件
funasr/runtime/python/websocket/ASR_client.py 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
funasr/runtime/python/websocket/ASR_server.py 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
funasr/runtime/python/websocket/ASR_client.py
@@ -6,6 +6,7 @@
from queue import Queue
# import threading
import argparse
import json
parser = argparse.ArgumentParser()
parser.add_argument("--host",
@@ -78,7 +79,9 @@
    global websocket
    while True:
        try:
            print(await websocket.recv())
            meg = await websocket.recv()
            meg = json.loads(meg)
            print(meg)
        except Exception as e:
            print("Exception:", e)          
        
funasr/runtime/python/websocket/ASR_server.py
@@ -4,6 +4,7 @@
from queue import Queue
import threading
import argparse
import json
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
@@ -157,7 +158,8 @@
                        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)