mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2025-04-06 03:57:44 +08:00
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
# -*- coding:utf-8 -*-
|
|
|
|
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)
|
|
|
|
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"
|
|
|
|
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 = 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())
|
|
|
|
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))
|