From a149107c5a1f461cba5506e23d993f31f1d85421 Mon Sep 17 00:00:00 2001 From: EntropyRiser <82279347+EntropyRiser@users.noreply.github.com> Date: Thu, 27 Apr 2023 18:52:01 +0800 Subject: [PATCH] Add full support of all samplerate. (#182) Co-authored-by: EntropyRiser <1832783120@qq.com> --- gui.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gui.py b/gui.py index 4146c63..f164829 100644 --- a/gui.py +++ b/gui.py @@ -52,7 +52,7 @@ class RVC: self.model = self.model.half() self.model.eval() cpt = torch.load(pth_path, map_location="cpu") - tgt_sr = cpt["config"][-1] + self.tgt_sr = cpt["config"][-1] cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk self.if_f0 = cpt.get("f0", 1) if self.if_f0 == 1: @@ -374,10 +374,10 @@ class GUI: self.block_frame = int(self.config.block_time * self.config.samplerate) self.crossfade_frame = int(self.config.crossfade_time * self.config.samplerate) self.sola_search_frame = int(0.012 * self.config.samplerate) - self.delay_frame = int(0.02 * self.config.samplerate) # 往前预留0.02s + self.delay_frame = int(0.01 * self.config.samplerate) # 往前预留0.02s self.extra_frame = int( self.config.extra_time * self.config.samplerate - ) # 往后预留0.04s + ) self.rvc = None self.rvc = RVC( self.config.pitch, @@ -408,7 +408,7 @@ class GUI: orig_freq=self.config.samplerate, new_freq=16000, dtype=torch.float32 ) self.resampler2 = tat.Resample( - orig_freq=40000, new_freq=self.config.samplerate, dtype=torch.float32 + orig_freq=self.rvc.tgt_sr, new_freq=self.config.samplerate, dtype=torch.float32 ) thread_vc = threading.Thread(target=self.soundinput) thread_vc.start()