From 17ef9ec1001f878a9d04080b8a98f4e86310763d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=B8=E9=9B=81?= Date: Mon, 22 Jan 2024 12:13:30 +0800 Subject: [PATCH 1/3] damo asr funasr1.0 --- README.md | 2 +- requirements.txt | 2 +- tools/damo_asr/cmd-asr.py | 23 +++++++++++++---------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 127aebf..00ffc13 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ pip install torch numpy scipy tensorboard librosa==0.9.2 numba==0.56.4 pytorch-l If you need Chinese ASR (supported by FunASR), install: ```bash -pip install modelscope torchaudio sentencepiece funasr +pip install modelscope torchaudio sentencepiece funasr>=1.0.0 ``` #### FFmpeg diff --git a/requirements.txt b/requirements.txt index fedce8a..5a7b3b3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ gradio==3.14.0 ffmpeg-python onnxruntime tqdm -funasr +funasr>=1.0.0 cn2an pypinyin pyopenjtalk diff --git a/tools/damo_asr/cmd-asr.py b/tools/damo_asr/cmd-asr.py index 2775562..aeed8ec 100644 --- a/tools/damo_asr/cmd-asr.py +++ b/tools/damo_asr/cmd-asr.py @@ -1,9 +1,11 @@ # -*- coding:utf-8 -*- -from modelscope.pipelines import pipeline -from modelscope.utils.constant import Tasks import sys,os,traceback + +from funasr import AutoModel + dir=sys.argv[1] + # opt_name=dir.split("\\")[-1].split("/")[-1] opt_name=os.path.basename(dir) @@ -13,17 +15,19 @@ path_punc='tools/damo_asr/models/punc_ct-transformer_zh-cn-common-vocab272727-py path_asr=path_asr if os.path.exists(path_asr)else "damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch" path_vad=path_vad if os.path.exists(path_vad)else "damo/speech_fsmn_vad_zh-cn-16k-common-pytorch" path_punc=path_punc if os.path.exists(path_punc)else "damo/punc_ct-transformer_zh-cn-common-vocab272727-pytorch" -inference_pipeline = pipeline( - task=Tasks.auto_speech_recognition, - model=path_asr, - vad_model=path_vad, - punc_model=path_punc, -) + +model = AutoModel(model=path_asr, model_revision="v2.0.3", + vad_model=path_vad, + vad_model_revision="v2.0.2", + punc_model=path_punc, + punc_model_revision="v2.0.3", + ) + opt=[] for name in os.listdir(dir): try: - text = inference_pipeline(audio_in="%s/%s"%(dir,name))["text"] + text = model.generate(input="%s/%s"%(dir,name))[0]["text"] opt.append("%s/%s|%s|ZH|%s"%(dir,name,opt_name,text)) except: print(traceback.format_exc()) @@ -31,4 +35,3 @@ for name in os.listdir(dir): opt_dir="output/asr_opt" os.makedirs(opt_dir,exist_ok=True) with open("%s/%s.list"%(opt_dir,opt_name),"w",encoding="utf-8")as f:f.write("\n".join(opt)) - From 8db49144978ce972e1cb768f440e95a8b7267467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=B8=E9=9B=81?= Date: Tue, 23 Jan 2024 21:11:15 +0800 Subject: [PATCH 2/3] funasr1.0.0 --- tools/damo_asr/cmd-asr.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/damo_asr/cmd-asr.py b/tools/damo_asr/cmd-asr.py index aeed8ec..b6d9263 100644 --- a/tools/damo_asr/cmd-asr.py +++ b/tools/damo_asr/cmd-asr.py @@ -5,7 +5,6 @@ import sys,os,traceback from funasr import AutoModel dir=sys.argv[1] - # opt_name=dir.split("\\")[-1].split("/")[-1] opt_name=os.path.basename(dir) @@ -16,11 +15,11 @@ path_asr=path_asr if os.path.exists(path_asr)else "damo/speech_paraformer-large_ path_vad=path_vad if os.path.exists(path_vad)else "damo/speech_fsmn_vad_zh-cn-16k-common-pytorch" path_punc=path_punc if os.path.exists(path_punc)else "damo/punc_ct-transformer_zh-cn-common-vocab272727-pytorch" -model = AutoModel(model=path_asr, model_revision="v2.0.3", +model = AutoModel(model=path_asr, model_revision="v2.0.4", vad_model=path_vad, - vad_model_revision="v2.0.2", + vad_model_revision="v2.0.4", punc_model=path_punc, - punc_model_revision="v2.0.3", + punc_model_revision="v2.0.4", ) From 49db21d0528011503cbfd1341bd01e0e27eeb66d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=B8=E9=9B=81?= Date: Tue, 23 Jan 2024 21:36:13 +0800 Subject: [PATCH 3/3] rename damo to iic --- tools/damo_asr/cmd-asr.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/damo_asr/cmd-asr.py b/tools/damo_asr/cmd-asr.py index b6d9263..70dd4d8 100644 --- a/tools/damo_asr/cmd-asr.py +++ b/tools/damo_asr/cmd-asr.py @@ -11,9 +11,9 @@ opt_name=os.path.basename(dir) path_asr='tools/damo_asr/models/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch' path_vad='tools/damo_asr/models/speech_fsmn_vad_zh-cn-16k-common-pytorch' path_punc='tools/damo_asr/models/punc_ct-transformer_zh-cn-common-vocab272727-pytorch' -path_asr=path_asr if os.path.exists(path_asr)else "damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch" -path_vad=path_vad if os.path.exists(path_vad)else "damo/speech_fsmn_vad_zh-cn-16k-common-pytorch" -path_punc=path_punc if os.path.exists(path_punc)else "damo/punc_ct-transformer_zh-cn-common-vocab272727-pytorch" +path_asr=path_asr if os.path.exists(path_asr)else "iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch" +path_vad=path_vad if os.path.exists(path_vad)else "iic/speech_fsmn_vad_zh-cn-16k-common-pytorch" +path_punc=path_punc if os.path.exists(path_punc)else "iic/punc_ct-transformer_zh-cn-common-vocab272727-pytorch" model = AutoModel(model=path_asr, model_revision="v2.0.4", vad_model=path_vad,