Spaces:
Running
Running
, weights_only=False
Browse files- _run.py +1 -1
- models.py +3 -3
- styletts2importable.py +3 -3
_run.py
CHANGED
|
@@ -99,7 +99,7 @@ model = build_model(model_params, text_aligner, pitch_extractor, plbert)
|
|
| 99 |
_ = [model[key].eval() for key in model]
|
| 100 |
_ = [model[key].to(device) for key in model]
|
| 101 |
|
| 102 |
-
params_whole = torch.load("Models/LibriTTS/epochs_2nd_00020.pth", map_location='cpu')
|
| 103 |
params = params_whole['net']
|
| 104 |
|
| 105 |
for key in model:
|
|
|
|
| 99 |
_ = [model[key].eval() for key in model]
|
| 100 |
_ = [model[key].to(device) for key in model]
|
| 101 |
|
| 102 |
+
params_whole = torch.load("Models/LibriTTS/epochs_2nd_00020.pth", map_location='cpu', weights_only=False)
|
| 103 |
params = params_whole['net']
|
| 104 |
|
| 105 |
for key in model:
|
models.py
CHANGED
|
@@ -722,7 +722,7 @@ def load_F0_models(path):
|
|
| 722 |
# load F0 model
|
| 723 |
|
| 724 |
F0_model = JDCNet(num_class=1, seq_len=192)
|
| 725 |
-
params = torch.load(path, map_location="cpu")["net"]
|
| 726 |
F0_model.load_state_dict(params)
|
| 727 |
_ = F0_model.train()
|
| 728 |
|
|
@@ -739,7 +739,7 @@ def load_ASR_models(ASR_MODEL_PATH, ASR_MODEL_CONFIG):
|
|
| 739 |
|
| 740 |
def _load_model(model_config, model_path):
|
| 741 |
model = ASRCNN(**model_config)
|
| 742 |
-
params = torch.load(model_path, map_location="cpu")["model"]
|
| 743 |
model.load_state_dict(params)
|
| 744 |
return model
|
| 745 |
|
|
@@ -862,7 +862,7 @@ def build_model(args, text_aligner, pitch_extractor, bert):
|
|
| 862 |
|
| 863 |
|
| 864 |
def load_checkpoint(model, optimizer, path, load_only_params=True, ignore_modules=[]):
|
| 865 |
-
state = torch.load(path, map_location="cpu")
|
| 866 |
params = state["net"]
|
| 867 |
for key in model:
|
| 868 |
if key in params and key not in ignore_modules:
|
|
|
|
| 722 |
# load F0 model
|
| 723 |
|
| 724 |
F0_model = JDCNet(num_class=1, seq_len=192)
|
| 725 |
+
params = torch.load(path, map_location="cpu", weights_only=False)["net"]
|
| 726 |
F0_model.load_state_dict(params)
|
| 727 |
_ = F0_model.train()
|
| 728 |
|
|
|
|
| 739 |
|
| 740 |
def _load_model(model_config, model_path):
|
| 741 |
model = ASRCNN(**model_config)
|
| 742 |
+
params = torch.load(model_path, map_location="cpu", weights_only=False)["model"]
|
| 743 |
model.load_state_dict(params)
|
| 744 |
return model
|
| 745 |
|
|
|
|
| 862 |
|
| 863 |
|
| 864 |
def load_checkpoint(model, optimizer, path, load_only_params=True, ignore_modules=[]):
|
| 865 |
+
state = torch.load(path, map_location="cpu", weights_only=False)
|
| 866 |
params = state["net"]
|
| 867 |
for key in model:
|
| 868 |
if key in params and key not in ignore_modules:
|
styletts2importable.py
CHANGED
|
@@ -105,7 +105,7 @@ _ = [model[key].eval() for key in model]
|
|
| 105 |
_ = [model[key].to(device) for key in model]
|
| 106 |
|
| 107 |
# params_whole = torch.load("Models/LibriTTS/epochs_2nd_00020.pth", map_location='cpu')
|
| 108 |
-
params_whole = torch.load(str(cached_path("hf://yl4579/StyleTTS2-LibriTTS/Models/LibriTTS/epochs_2nd_00020.pth")), map_location='cpu')
|
| 109 |
params = params_whole['net']
|
| 110 |
|
| 111 |
for key in model:
|
|
@@ -169,7 +169,7 @@ def inference(text, ref_s, lang='en-us', alpha = 0.3, beta = 0.7, diffusion_step
|
|
| 169 |
# replace IPA sections with []
|
| 170 |
if (ipa_sections is not None):
|
| 171 |
text = re.sub(regex, '[]', text, 0, re.MULTILINE)
|
| 172 |
-
|
| 173 |
if lang in LANG_NAMES:
|
| 174 |
local_phonemizer = phonemizer.backend.EspeakBackend(language=lang, preserve_punctuation=True, with_stress=True)
|
| 175 |
ps = local_phonemizer.phonemize([text])
|
|
@@ -186,7 +186,7 @@ def inference(text, ref_s, lang='en-us', alpha = 0.3, beta = 0.7, diffusion_step
|
|
| 186 |
if (ipa_sections is not None):
|
| 187 |
for ipa in ipa_sections:
|
| 188 |
ps = ps.replace('[ ]', ipa, 1)
|
| 189 |
-
|
| 190 |
tokens = textclenaer(ps)
|
| 191 |
tokens.insert(0, 0)
|
| 192 |
tokens = torch.LongTensor(tokens).to(device).unsqueeze(0)
|
|
|
|
| 105 |
_ = [model[key].to(device) for key in model]
|
| 106 |
|
| 107 |
# params_whole = torch.load("Models/LibriTTS/epochs_2nd_00020.pth", map_location='cpu')
|
| 108 |
+
params_whole = torch.load(str(cached_path("hf://yl4579/StyleTTS2-LibriTTS/Models/LibriTTS/epochs_2nd_00020.pth")), map_location='cpu', weights_only=False)
|
| 109 |
params = params_whole['net']
|
| 110 |
|
| 111 |
for key in model:
|
|
|
|
| 169 |
# replace IPA sections with []
|
| 170 |
if (ipa_sections is not None):
|
| 171 |
text = re.sub(regex, '[]', text, 0, re.MULTILINE)
|
| 172 |
+
|
| 173 |
if lang in LANG_NAMES:
|
| 174 |
local_phonemizer = phonemizer.backend.EspeakBackend(language=lang, preserve_punctuation=True, with_stress=True)
|
| 175 |
ps = local_phonemizer.phonemize([text])
|
|
|
|
| 186 |
if (ipa_sections is not None):
|
| 187 |
for ipa in ipa_sections:
|
| 188 |
ps = ps.replace('[ ]', ipa, 1)
|
| 189 |
+
|
| 190 |
tokens = textclenaer(ps)
|
| 191 |
tokens.insert(0, 0)
|
| 192 |
tokens = torch.LongTensor(tokens).to(device).unsqueeze(0)
|