实时GUI支持rmvpe

实时GUI支持rmvpe
This commit is contained in:
RVC-Boss
2023-07-11 16:27:18 +08:00
committed by GitHub
parent c69cecbc41
commit 0f9d2e6cac
2 changed files with 23 additions and 7 deletions

View File

@@ -81,6 +81,7 @@ class RVC:
self.net_g = self.net_g.half()
else:
self.net_g = self.net_g.float()
self.is_half=config.is_half
except:
print(traceback.format_exc())
@@ -102,6 +103,7 @@ class RVC:
def get_f0(self, x, f0_up_key, n_cpu, method="harvest"):
n_cpu = int(n_cpu)
if (method == "crepe"): return self.get_f0_crepe(x, f0_up_key)
if (method == "rmvpe"): return self.get_f0_rmvpe(x, f0_up_key)
if (method == "pm"):
p_len = x.shape[0] // 160
f0 = (
@@ -181,6 +183,16 @@ class RVC:
f0 *= pow(2, f0_up_key / 12)
return self.get_f0_post(f0)
def get_f0_rmvpe(self, x, f0_up_key):
if (hasattr(self, "model_rmvpe") == False):
from rmvpe import RMVPE
print("loading rmvpe model")
# self.model_rmvpe = RMVPE("rmvpe.pt", is_half=self.is_half, device=self.device)
self.model_rmvpe = RMVPE("aug2_58000_half.pt", is_half=self.is_half, device=self.device)
f0 = self.model_rmvpe.infer_from_audio(x, thred=0.03)
f0 *= pow(2, f0_up_key / 12)
return self.get_f0_post(f0)
def infer(self, feats: torch.Tensor, indata: np.ndarray, rate1, rate2, cache_pitch, cache_pitchf, f0method) -> np.ndarray:
feats = feats.view(1, -1)
if config.is_half: