-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #287 from chmod740/add_fun_asr
feat:添加funasr语音识别框架支持
- Loading branch information
Showing
4 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,5 @@ openai | |
apscheduler | ||
asyncio | ||
edge-tts | ||
nest_asyncio | ||
nest_asyncio | ||
funasr_onnx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
from typing import Any | ||
|
||
|
||
class funASREngine(object): | ||
def __init__(self, inference_type, model_dir=''): | ||
assert inference_type in ['onnxruntime'] # 当前只实现了onnxruntime的推理方案 | ||
self.inference_type = inference_type | ||
if self.inference_type == 'onnxruntime': | ||
# 调用下面的引擎进初始化引擎太慢了,因此放在条件分支里面 | ||
from funasr_onnx import Paraformer | ||
self.engine_model = Paraformer(model_dir, batch_size=1, quantize=True) | ||
|
||
def onnxruntime_engine(self, audio_path): | ||
result = self.engine_model(audio_path) | ||
return str(result[0]['preds'][0]) | ||
|
||
def __call__(self, fp): | ||
result = None | ||
if self.inference_type == 'onnxruntime': | ||
result = self.onnxruntime_engine(fp) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters