1
0
mirror of https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git synced 2026-06-07 19:40:44 +08:00

optimize(f0): move fcpe into rvc.f0

This commit is contained in:
源文雨
2024-06-14 21:33:46 +09:00
parent 24dbc5edd2
commit 3b7d7c6d1a
6 changed files with 70 additions and 32 deletions

View File

@@ -13,7 +13,6 @@ import scipy.signal as signal
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchcrepe
from torchaudio.transforms import Resample
from rvc.synthesizer import load_synthesizer
@@ -323,20 +322,17 @@ class RVC:
def get_f0_fcpe(self, x, f0_up_key):
if hasattr(self, "model_fcpe") == False:
from torchfcpe import spawn_bundled_infer_model
from rvc.f0 import FCPE
printt("Loading fcpe model")
if "privateuseone" in str(self.device):
self.device_fcpe = "cpu"
else:
self.device_fcpe = self.device
self.model_fcpe = spawn_bundled_infer_model(self.device_fcpe)
f0 = self.model_fcpe.infer(
x.to(self.device_fcpe).unsqueeze(0).float(),
sr=16000,
decoder_mode="local_argmax",
threshold=0.006,
)
self.model_fcpe = FCPE(
160,
self.f0_min,
self.f0_max,
16000,
self.device,
)
f0 = self.model_fcpe.compute_f0(x)
f0 *= pow(2, f0_up_key / 12)
return self.get_f0_post(f0)

View File

@@ -14,7 +14,7 @@ import torch
import torch.nn.functional as F
from scipy import signal
from rvc.f0 import PM, Harvest, RMVPE, CRePE, Dio
from rvc.f0 import PM, Harvest, RMVPE, CRePE, Dio, FCPE
now_dir = os.getcwd()
sys.path.append(now_dir)
@@ -118,21 +118,15 @@ class Pipeline(object):
elif f0_method == "fcpe":
if not hasattr(self, "model_fcpe"):
from torchfcpe import spawn_bundled_infer_model
logger.info("Loading fcpe model")
self.model_fcpe = spawn_bundled_infer_model(self.device)
f0 = (
self.model_fcpe.infer(
torch.from_numpy(x).to(self.device).unsqueeze(0).float(),
sr=16000,
decoder_mode="local_argmax",
threshold=0.006,
self.model_fcpe = FCPE(
self.window,
f0_min,
f0_max,
self.sr,
self.device,
)
.squeeze()
.cpu()
.numpy()
)
f0 = self.model_fcpe.compute_f0(x, p_len=p_len)
f0 *= pow(2, f0_up_key / 12)
# with open("test.txt","w")as f:f.write("\n".join([str(i)for i in f0.tolist()]))