1
0
mirror of https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git synced 2026-06-10 21:24:16 +08:00

optimize(vc.hash): use general get_synthesizer

This commit is contained in:
源文雨
2024-06-05 15:19:05 +09:00
parent bb675b1e45
commit e80074e219
3 changed files with 10 additions and 25 deletions

View File

@@ -1,2 +1,2 @@
from .utils import load, rmvpe_jit_export, synthesizer_jit_export
from .synthesizer import get_synthesizer
from .synthesizer import get_synthesizer, get_synthesizer_ckpt

View File

@@ -1,7 +1,6 @@
import torch
def get_synthesizer(pth_path, device=torch.device("cpu")):
def get_synthesizer_ckpt(cpt, device=torch.device("cpu")):
from infer.lib.infer_pack.models import (
SynthesizerTrnMs256NSFsid,
SynthesizerTrnMs256NSFsid_nono,
@@ -9,7 +8,6 @@ def get_synthesizer(pth_path, device=torch.device("cpu")):
SynthesizerTrnMs768NSFsid_nono,
)
cpt = torch.load(pth_path, map_location=torch.device("cpu"))
# tgt_sr = cpt["config"][-1]
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0]
if_f0 = cpt.get("f0", 1)
@@ -36,3 +34,8 @@ def get_synthesizer(pth_path, device=torch.device("cpu")):
net_g.eval().to(device)
net_g.remove_weight_norm()
return net_g, cpt
def get_synthesizer(pth_path, device=torch.device("cpu")):
return get_synthesizer_ckpt(
torch.load(pth_path, map_location=torch.device("cpu")), device,
)