From 66049c3c063ab72f820b4dc8b242d00465802318 Mon Sep 17 00:00:00 2001 From: nadare <1na2da0re3@gmail.com> Date: Fri, 7 Jul 2023 08:56:25 +0900 Subject: [PATCH] =?UTF-8?q?hotfix=20protect=E3=81=82=E3=82=8A=E3=81=AE?= =?UTF-8?q?=E6=99=82=E7=89=B9=E5=AE=9A=E3=81=AEchunksize=E3=81=A7=E3=83=90?= =?UTF-8?q?=E3=82=B0=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/voice_changer/RVC/pipeline/Pipeline.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/server/voice_changer/RVC/pipeline/Pipeline.py b/server/voice_changer/RVC/pipeline/Pipeline.py index fbb8f23f..eef0fe4d 100644 --- a/server/voice_changer/RVC/pipeline/Pipeline.py +++ b/server/voice_changer/RVC/pipeline/Pipeline.py @@ -189,6 +189,12 @@ class Pipeline(object): pitch = pitch[:, :p_len] pitchf = pitchf[:, :p_len] + feats_len = feats.shape[1] + if pitch is not None and pitchf is not None: + pitch = pitch[:, -feats_len:] + pitchf = pitchf[:, -feats_len:] + p_len = torch.tensor([feats_len], device=self.device).long() + # pitchの推定が上手くいかない(pitchf=0)場合、検索前の特徴を混ぜる # pitchffの作り方の疑問はあるが、本家通りなので、このまま使うことにする。 # https://github.com/w-okada/voice-changer/pull/276#issuecomment-1571336929 @@ -201,23 +207,11 @@ class Pipeline(object): feats = feats.to(feats0.dtype) p_len = torch.tensor([p_len], device=self.device).long() - feats_buffer = feats.squeeze(0).detach().cpu() - if pitchf is not None: - pitchf_buffer = pitchf.squeeze(0).detach().cpu() - else: - pitchf_buffer = None # apply silent front for inference if type(self.inferencer) in [OnnxRVCInferencer, OnnxRVCInferencerNono]: npyOffset = math.floor(silence_front * 16000) // 360 feats = feats[:, npyOffset * 2 :, :] - - feats_len = feats.shape[1] - if pitch is not None and pitchf is not None: - pitch = pitch[:, -feats_len:] - pitchf = pitchf[:, -feats_len:] - p_len = torch.tensor([feats_len], device=self.device).long() - # 推論実行 try: with torch.no_grad(): @@ -237,6 +231,12 @@ class Pipeline(object): else: raise e + feats_buffer = feats.squeeze(0).detach().cpu() + if pitchf is not None: + pitchf_buffer = pitchf.squeeze(0).detach().cpu() + else: + pitchf_buffer = None + del p_len, padding_mask, pitch, pitchf, feats torch.cuda.empty_cache()