1
0
mirror of synced 2024-11-27 17:00:54 +01:00

Add full support of all samplerate. (#182)

Co-authored-by: EntropyRiser <1832783120@qq.com>
This commit is contained in:
EntropyRiser 2023-04-27 18:52:01 +08:00 committed by GitHub
parent 80b54499eb
commit a149107c5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

8
gui.py
View File

@ -52,7 +52,7 @@ class RVC:
self.model = self.model.half() self.model = self.model.half()
self.model.eval() self.model.eval()
cpt = torch.load(pth_path, map_location="cpu") 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 cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
self.if_f0 = cpt.get("f0", 1) self.if_f0 = cpt.get("f0", 1)
if self.if_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.block_frame = int(self.config.block_time * self.config.samplerate)
self.crossfade_frame = int(self.config.crossfade_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.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.extra_frame = int(
self.config.extra_time * self.config.samplerate self.config.extra_time * self.config.samplerate
) # 往后预留0.04s )
self.rvc = None self.rvc = None
self.rvc = RVC( self.rvc = RVC(
self.config.pitch, self.config.pitch,
@ -408,7 +408,7 @@ class GUI:
orig_freq=self.config.samplerate, new_freq=16000, dtype=torch.float32 orig_freq=self.config.samplerate, new_freq=16000, dtype=torch.float32
) )
self.resampler2 = tat.Resample( 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 = threading.Thread(target=self.soundinput)
thread_vc.start() thread_vc.start()