From 88a43e14d164222d13451af1140dbbbf22da5324 Mon Sep 17 00:00:00 2001 From: EntropyRiser <82279347+EntropyRiser@users.noreply.github.com> Date: Mon, 17 Apr 2023 20:49:42 +0800 Subject: [PATCH] Add non-search inference support. (#82) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com> --- gui.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gui.py b/gui.py index db9a8d6..ecd1d81 100644 --- a/gui.py +++ b/gui.py @@ -16,7 +16,6 @@ from infer_pack.models import SynthesizerTrnMs256NSFsid, SynthesizerTrnMs256NSFs from i18n import I18nAuto i18n = I18nAuto() -print(i18n.language_map) device = torch.device("cuda" if torch.cuda.is_available() else "cpu") @@ -33,10 +32,11 @@ class RVC: self.f0_max = 1100 self.f0_mel_min = 1127 * np.log(1 + self.f0_min / 700) self.f0_mel_max = 1127 * np.log(1 + self.f0_max / 700) - self.index = faiss.read_index(index_path) + if index_rate !=0: + self.index = faiss.read_index(index_path) + self.big_npy = np.load(npy_path) + print('index search enabled') self.index_rate = index_rate - """NOT YET USED""" - self.big_npy = np.load(npy_path) model_path = hubert_path print("load model(s) from {}".format(model_path)) models, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_task( @@ -112,8 +112,8 @@ class RVC: ####索引优化 if ( - isinstance(self.index, type(None)) == False - and isinstance(self.big_npy, type(None)) == False + hasattr(self,'index') + and hasattr(self,'big_npy') and self.index_rate != 0 ): npy = feats[0].cpu().numpy().astype("float32") @@ -123,6 +123,8 @@ class RVC: torch.from_numpy(npy).unsqueeze(0).to(device) * self.index_rate + (1 - self.index_rate) * feats ) + else: + print('index search FAIL or disabled') feats = F.interpolate(feats.permute(0, 2, 1), scale_factor=2).permute(0, 2, 1) torch.cuda.synchronize()