From 512f20d0bfb48758a829a1840d2e9544e0d6baf3 Mon Sep 17 00:00:00 2001 From: iftaken Date: Wed, 21 Sep 2022 14:00:32 +0800 Subject: [PATCH] fixed get_cmd and use MAIN_ROOT in ge2e --- .../speech_web/speech_server/src/ernie_sat.py | 91 ++++++++++++------- .../speech_server/src/ge2e_clone.py | 6 +- 2 files changed, 60 insertions(+), 37 deletions(-) diff --git a/demos/speech_web/speech_server/src/ernie_sat.py b/demos/speech_web/speech_server/src/ernie_sat.py index 91a8915a7..b74dd8e3f 100644 --- a/demos/speech_web/speech_server/src/ernie_sat.py +++ b/demos/speech_web/speech_server/src/ernie_sat.py @@ -52,19 +52,19 @@ class SAT: voc_stat = os.path.join(self.zh_voc_model_path, "feats_stats.npy") cmd = self.get_cmd( - task_name, - input_name, - old_str, - new_str, - config_path, - phones_dict, - erniesat_ckpt, - erniesat_stat, - voc, - voc_config, - voc_ckpt, - voc_stat, - output_name, + task_name=task_name, + input_name=input_name, + old_str=old_str, + new_str=new_str, + config_path=config_path, + phones_dict=phones_dict, + erniesat_ckpt=erniesat_ckpt, + erniesat_stat=erniesat_stat, + voc=voc, + voc_config=voc_config, + voc_ckpt=voc_ckpt, + voc_stat=voc_stat, + output_name=output_name, source_lang="zh", target_lang="zh") @@ -94,10 +94,22 @@ class SAT: "snapshot_iter_2500000.pdz") voc_stat = os.path.join(self.cross_voc_model_path, "feats_stats.npy") task_name = "synthesize" - cmd = self.get_cmd(task_name, input_name, old_str, new_str, config_path, - phones_dict, erniesat_ckpt, erniesat_stat, voc, - voc_config, voc_ckpt, voc_stat, output_name, - source_lang, target_lang) + cmd = self.get_cmd( + task_name=task_name, + input_name=input_name, + old_str=old_str, + new_str=new_str, + config_path=config_path, + phones_dict=phones_dict, + erniesat_ckpt=erniesat_ckpt, + erniesat_stat=erniesat_stat, + voc=voc, + voc_config=voc_config, + voc_ckpt=voc_ckpt, + voc_stat=voc_stat, + output_name=output_name, + source_lang=source_lang, + target_lang=target_lang) return run_cmd(cmd, output_name) @@ -125,27 +137,40 @@ class SAT: voc_stat = os.path.join(self.zh_voc_model_path, "feats_stats.npy") cmd = self.get_cmd( - task_name, - input_name, - old_str, - new_str, - config_path, - phones_dict, - erniesat_ckpt, - erniesat_stat, - voc, - voc_config, - voc_ckpt, - voc_stat, - output_name, + task_name=task_name, + input_name=input_name, + old_str=old_str, + new_str=new_str, + config_path=config_path, + phones_dict=phones_dict, + erniesat_ckpt=erniesat_ckpt, + erniesat_stat=erniesat_stat, + voc=voc, + voc_config=voc_config, + voc_ckpt=voc_ckpt, + voc_stat=voc_stat, + output_name=output_name, source_lang="en", target_lang="en") return run_cmd(cmd, output_name) - def get_cmd(self, task_name, input_name, old_str, new_str, config_path, - phones_dict, erniesat_ckpt, erniesat_stat, voc, voc_config, - voc_ckpt, voc_stat, output_name, source_lang, target_lang): + def get_cmd(self, + task_name: str, + input_name: str, + old_str: str, + new_str: str, + config_path: str, + phones_dict: str, + erniesat_ckpt: str, + erniesat_stat: str, + voc: str, + voc_config: str, + voc_ckpt: str, + voc_stat: str, + output_name: str, + source_lang: str, + target_lang: str): cmd = f""" FLAGS_allocator_strategy=naive_best_fit \ FLAGS_fraction_of_gpu_memory_to_use=0.01 \ diff --git a/demos/speech_web/speech_server/src/ge2e_clone.py b/demos/speech_web/speech_server/src/ge2e_clone.py index 18173bd33..d90013b98 100644 --- a/demos/speech_web/speech_server/src/ge2e_clone.py +++ b/demos/speech_web/speech_server/src/ge2e_clone.py @@ -1,16 +1,14 @@ import os import shutil +from .util import MAIN_ROOT from .util import run_cmd class VoiceCloneGE2E(): def __init__(self): # Path 到指定路径上 - self.now_file_path = os.path.dirname(__file__) - self.BIN_DIR = os.path.realpath( - os.path.join(self.now_file_path, - "../../../../paddlespeech/t2s/exps")) + self.BIN_DIR = os.path.join(MAIN_ROOT, "paddlespeech/t2s/exps") # am self.am = "fastspeech2_aishell3" self.am_config = "source/model/fastspeech2_nosil_aishell3_vc1_ckpt_0.5/default.yaml"