From 54ef90fcecdd6429c94ca401e05b1623ed382e49 Mon Sep 17 00:00:00 2001 From: TianYuan Date: Thu, 6 Apr 2023 17:38:18 +0800 Subject: [PATCH] [TTS]Fix VITS lite infer (#3098) --- examples/csmsc/vits/local/lite_predict.sh | 2 +- examples/csmsc/vits/run.sh | 22 +++++++++++----------- paddlespeech/t2s/exps/vits/lite_predict.py | 7 ++++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/examples/csmsc/vits/local/lite_predict.sh b/examples/csmsc/vits/local/lite_predict.sh index 9ed57b727..e12f53493 100755 --- a/examples/csmsc/vits/local/lite_predict.sh +++ b/examples/csmsc/vits/local/lite_predict.sh @@ -7,7 +7,7 @@ stage=0 stop_stage=0 if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then - python3 ${BIN_DIR}/../lite_predict.py \ + python3 ${BIN_DIR}/lite_predict.py \ --inference_dir=${train_output_path}/pdlite \ --am=vits_csmsc \ --text=${BIN_DIR}/../sentences.txt \ diff --git a/examples/csmsc/vits/run.sh b/examples/csmsc/vits/run.sh index 03c59702b..f6e8a086c 100755 --- a/examples/csmsc/vits/run.sh +++ b/examples/csmsc/vits/run.sh @@ -54,16 +54,16 @@ fi # ./local/ort_predict.sh ${train_output_path} # fi -# # not ready yet for operator missing in Paddle-Lite -# # must run after stage 3 (which stage generated static models) -# if [ ${stage} -le 7 ] && [ ${stop_stage} -ge 7 ]; then -# # NOTE by yuantian 2022.11.21: please compile develop version of Paddle-Lite to export and run TTS models, -# # cause TTS models are supported by https://github.com/PaddlePaddle/Paddle-Lite/pull/9587 -# # and https://github.com/PaddlePaddle/Paddle-Lite/pull/9706 -# ./local/export2lite.sh ${train_output_path} inference pdlite vits_csmsc x86 -# fi +# not ready yet for operator missing in Paddle-Lite +# must run after stage 3 (which stage generated static models) +if [ ${stage} -le 7 ] && [ ${stop_stage} -ge 7 ]; then + # NOTE by yuantian 2022.11.21: please compile develop version of Paddle-Lite to export and run TTS models, + # cause TTS models are supported by https://github.com/PaddlePaddle/Paddle-Lite/pull/10128 + # vits can only run in arm + ./local/export2lite.sh ${train_output_path} inference pdlite vits_csmsc arm +fi -# if [ ${stage} -le 8 ] && [ ${stop_stage} -ge 8 ]; then -# CUDA_VISIBLE_DEVICES=${gpus} ./local/lite_predict.sh ${train_output_path} || exit -1 -# fi +if [ ${stage} -le 8 ] && [ ${stop_stage} -ge 8 ]; then + CUDA_VISIBLE_DEVICES=${gpus} ./local/lite_predict.sh ${train_output_path} || exit -1 +fi diff --git a/paddlespeech/t2s/exps/vits/lite_predict.py b/paddlespeech/t2s/exps/vits/lite_predict.py index 790cd48e3..32a544b7f 100644 --- a/paddlespeech/t2s/exps/vits/lite_predict.py +++ b/paddlespeech/t2s/exps/vits/lite_predict.py @@ -21,6 +21,7 @@ from paddlespeech.t2s.exps.lite_syn_utils import get_lite_am_output from paddlespeech.t2s.exps.lite_syn_utils import get_lite_predictor from paddlespeech.t2s.exps.syn_utils import get_frontend from paddlespeech.t2s.exps.syn_utils import get_sentences +from paddlespeech.t2s.utils import str2bool def parse_args(): @@ -75,12 +76,12 @@ def main(): # frontend frontend = get_frontend( lang=args.lang, - phones_dict=args.phones_dict, - tones_dict=args.tones_dict) + phones_dict=args.phones_dict) # am_predictor + # vits can only run in arm am_predictor = get_lite_predictor( - model_dir=args.inference_dir, model_file=args.am + "_x86.nb") + model_dir=args.inference_dir, model_file=args.am + "_arm.nb") # model: {model_name}_{dataset} am_dataset = args.am[args.am.rindex('_') + 1:]