(model_name, seg_files, device="cuda:0")
| 87 | |
| 88 | |
| 89 | def run_pytorch(model_name, seg_files, device="cuda:0"): |
| 90 | from funasr import AutoModel |
| 91 | |
| 92 | kwargs = {"model": model_name, "device": device, "disable_update": True} |
| 93 | if "Fun-ASR-Nano" in model_name: |
| 94 | kwargs["trust_remote_code"] = True |
| 95 | kwargs["remote_code"] = os.path.join( |
| 96 | os.path.dirname(__file__), |
| 97 | "examples/industrial_data_pretraining/fun_asr_nano/model.py" |
| 98 | ) |
| 99 | |
| 100 | model = AutoModel(**kwargs) |
| 101 | model.generate(input=seg_files[0]) # warmup |
| 102 | |
| 103 | t0 = time.perf_counter() |
| 104 | texts = [] |
| 105 | for f in seg_files: |
| 106 | res = model.generate(input=f) |
| 107 | texts.append(res[0]["text"]) |
| 108 | t1 = time.perf_counter() |
| 109 | return t1 - t0, texts |
| 110 | |
| 111 | |
| 112 | def run_vllm(model_name, seg_files, device="cuda:0", hub="ms"): |
no test coverage detected
searching dependent graphs…