From 35bfdccfb23d6f067f4d0c3161a836dcc3b8fd68 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 21 Apr 2024 16:46:13 +0000 Subject: [PATCH] chore(format): run black on dev --- gui_v1.py | 2 +- infer/lib/infer_pack/models.py | 23 +++++++++++++++++------ infer/lib/rtrvc.py | 18 ++++++++++-------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/gui_v1.py b/gui_v1.py index 8a19301..2b30b00 100644 --- a/gui_v1.py +++ b/gui_v1.py @@ -356,7 +356,7 @@ if __name__ == "__main__": enable_events=True, ), ], - [ + [ sg.Text(i18n("共振偏移")), sg.Slider( range=(-5, 5), diff --git a/infer/lib/infer_pack/models.py b/infer/lib/infer_pack/models.py index 30d8ce4..a1a27e2 100644 --- a/infer/lib/infer_pack/models.py +++ b/infer/lib/infer_pack/models.py @@ -249,12 +249,17 @@ class Generator(torch.nn.Module): if gin_channels != 0: self.cond = nn.Conv1d(gin_channels, upsample_initial_channel, 1) - def forward(self, x: torch.Tensor, g: Optional[torch.Tensor] = None, n_res: Optional[torch.Tensor] = None): + def forward( + self, + x: torch.Tensor, + g: Optional[torch.Tensor] = None, + n_res: Optional[torch.Tensor] = None, + ): if n_res is not None: assert isinstance(n_res, torch.Tensor) n = int(n_res.item()) if n != x.shape[-1]: - x = F.interpolate(x, size=n, mode='linear') + x = F.interpolate(x, size=n, mode="linear") x = self.conv_pre(x) if g is not None: x = x + self.cond(g) @@ -532,17 +537,23 @@ class GeneratorNSF(torch.nn.Module): self.upp = math.prod(upsample_rates) self.lrelu_slope = modules.LRELU_SLOPE - - def forward(self, x, f0, g: Optional[torch.Tensor] = None, n_res: Optional[torch.Tensor] = None): + + def forward( + self, + x, + f0, + g: Optional[torch.Tensor] = None, + n_res: Optional[torch.Tensor] = None, + ): har_source, noi_source, uv = self.m_source(f0, self.upp) har_source = har_source.transpose(1, 2) if n_res is not None: assert isinstance(n_res, torch.Tensor) n = int(n_res.item()) if n * self.upp != har_source.shape[-1]: - har_source = F.interpolate(har_source, size=n*self.upp, mode='linear') + har_source = F.interpolate(har_source, size=n * self.upp, mode="linear") if n != x.shape[-1]: - x = F.interpolate(x, size=n, mode='linear') + x = F.interpolate(x, size=n, mode="linear") x = self.conv_pre(x) if g is not None: x = x + self.cond(g) diff --git a/infer/lib/rtrvc.py b/infer/lib/rtrvc.py index 086eedd..03698ee 100644 --- a/infer/lib/rtrvc.py +++ b/infer/lib/rtrvc.py @@ -78,7 +78,7 @@ class RVC: self.n_cpu = n_cpu self.use_jit = self.config.use_jit self.is_half = config.is_half - + if index_rate != 0: self.index = faiss.read_index(index_path) self.big_npy = self.index.reconstruct_n(0, self.index.ntotal) @@ -92,9 +92,9 @@ class RVC: self.cache_pitchf = torch.zeros( 1024, device=self.device, dtype=torch.float32 ) - + self.resample_kernel = {} - + if last_rvc is None: models, _, _ = fairseq.checkpoint_utils.load_model_ensemble_and_task( ["assets/hubert/hubert_base.pt"], @@ -191,10 +191,10 @@ class RVC: def change_key(self, new_key): self.f0_up_key = new_key - + def change_formant(self, new_formant): self.formant_shift = new_formant - + def change_index_rate(self, new_index_rate): if new_index_rate != 0 and self.index_rate == 0: self.index = faiss.read_index(self.index_path) @@ -442,11 +442,13 @@ class RVC: if upp_res != self.tgt_sr // 100: if upp_res not in self.resample_kernel: self.resample_kernel[upp_res] = Resample( - orig_freq=upp_res, - new_freq=self.tgt_sr // 100, + orig_freq=upp_res, + new_freq=self.tgt_sr // 100, dtype=torch.float32, ).to(self.device) - infered_audio = self.resample_kernel[upp_res](infered_audio[: ,: return_length * upp_res]) + infered_audio = self.resample_kernel[upp_res]( + infered_audio[:, : return_length * upp_res] + ) t5 = ttime() printt( "Spent time: fea = %.3fs, index = %.3fs, f0 = %.3fs, model = %.3fs",