Skip to content

fix: path ValueError #2326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions GPT_SoVITS/TTS_infer_pack/TTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ def init_t2s_weights(self, weights_path: str):
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
Expand All @@ -574,7 +576,7 @@ def init_vocoder(self, version: str):
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
Expand Down Expand Up @@ -605,7 +607,7 @@ def init_vocoder(self, version: str):
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
Expand Down
7 changes: 5 additions & 2 deletions GPT_SoVITS/text/chinese2.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
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,
)
Expand Down
2 changes: 1 addition & 1 deletion tools/i18n/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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):
Expand Down