From 9b72d61ad1a014c568e32e10ac939a9c38429708 Mon Sep 17 00:00:00 2001 From: CyberWon Date: Fri, 25 Apr 2025 17:43:52 +0800 Subject: [PATCH 1/3] fix: path ValueError --- tools/i18n/i18n.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/i18n/i18n.py b/tools/i18n/i18n.py index 4cd123f3..1de56dd3 100644 --- a/tools/i18n/i18n.py +++ b/tools/i18n/i18n.py @@ -2,7 +2,7 @@ import json import locale import os -I18N_JSON_DIR: os.PathLike = os.path.join(os.path.dirname(os.path.relpath(__file__)), "locale") +I18N_JSON_DIR: os.PathLike = os.path.join(os.path.dirname(os.path.abspath(__file__)), "locale") def load_language_list(language): From 4208e7635c46fb8ee81056d5d28c0ad9bdc11afa Mon Sep 17 00:00:00 2001 From: CyberWon Date: Fri, 25 Apr 2025 17:57:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9C=A8=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E8=BD=AF=E4=BB=B6import=E6=97=B6=EF=BC=8C=E6=89=BE?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E6=A8=A1=E5=9E=8B=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GPT_SoVITS/text/chinese2.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/GPT_SoVITS/text/chinese2.py b/GPT_SoVITS/text/chinese2.py index 612aa3a5..4d415fd5 100644 --- a/GPT_SoVITS/text/chinese2.py +++ b/GPT_SoVITS/text/chinese2.py @@ -31,9 +31,12 @@ if is_g2pw: from text.g2pw import G2PWPinyin, correct_pronunciation parent_directory = os.path.dirname(current_file_path) + # 防止作为第三方库导入时,找不到模型文件 + model_dir = os.path.join(current_file_path, "G2PWModel") + model_source = os.path.join(parent_directory, "pretrained_models/chinese-roberta-wwm-ext-large") g2pw = G2PWPinyin( - model_dir="GPT_SoVITS/text/G2PWModel", - model_source=os.environ.get("bert_path", "GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large"), + model_dir=model_dir, + model_source=os.environ.get("bert_path", model_source), v_to_u=False, neutral_tone_with_five=True, ) From 55ce445432d8600fd613a884341a734cb3fe617a Mon Sep 17 00:00:00 2001 From: CyberWon Date: Fri, 25 Apr 2025 18:19:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9C=A8=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E8=BD=AF=E4=BB=B6import=E6=97=B6=EF=BC=8C=E6=89=BE?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E6=A8=A1=E5=9E=8B=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GPT_SoVITS/TTS_infer_pack/TTS.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/GPT_SoVITS/TTS_infer_pack/TTS.py b/GPT_SoVITS/TTS_infer_pack/TTS.py index d20daee3..9017d396 100644 --- a/GPT_SoVITS/TTS_infer_pack/TTS.py +++ b/GPT_SoVITS/TTS_infer_pack/TTS.py @@ -565,6 +565,8 @@ class TTS: self.t2s_model = self.t2s_model.half() def init_vocoder(self, version: str): + # 防止第三方导入时,找不到模型文件 + root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if version == "v3": if self.vocoder is not None and self.vocoder.__class__.__name__ == "BigVGAN": return @@ -574,7 +576,7 @@ class TTS: self.empty_cache() self.vocoder = BigVGAN.from_pretrained( - "%s/GPT_SoVITS/pretrained_models/models--nvidia--bigvgan_v2_24khz_100band_256x" % (now_dir,), + f"{root_dir}/pretrained_models/models--nvidia--bigvgan_v2_24khz_100band_256x", use_cuda_kernel=False, ) # if True, RuntimeError: Ninja is required to load C++ extensions # remove weight norm in the model and set to eval mode @@ -605,7 +607,7 @@ class TTS: gin_channels=0, is_bias=True ) self.vocoder.remove_weight_norm() - state_dict_g = torch.load("%s/GPT_SoVITS/pretrained_models/gsv-v4-pretrained/vocoder.pth" % (now_dir,), map_location="cpu") + state_dict_g = torch.load(f"{root_dir}/pretrained_models/gsv-v4-pretrained/vocoder.pth", map_location="cpu") print("loading vocoder",self.vocoder.load_state_dict(state_dict_g)) self.vocoder_configs["sr"] = 48000