mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2025-01-31 02:32:51 +08:00
增加无f0模型的支持
增加无f0模型的支持
This commit is contained in:
parent
2f51e932bf
commit
c423f77a16
40
gui.py
40
gui.py
@ -54,8 +54,8 @@ class RVC:
|
|||||||
cpt = torch.load(pth_path, map_location="cpu")
|
cpt = torch.load(pth_path, map_location="cpu")
|
||||||
tgt_sr = cpt["config"][-1]
|
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
|
||||||
if_f0 = cpt.get("f0", 1)
|
self.if_f0 = cpt.get("f0", 1)
|
||||||
if if_f0 == 1:
|
if self.if_f0 == 1:
|
||||||
self.net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=True)
|
self.net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=True)
|
||||||
else:
|
else:
|
||||||
self.net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
|
self.net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
|
||||||
@ -136,27 +136,37 @@ class RVC:
|
|||||||
|
|
||||||
feats = F.interpolate(feats.permute(0, 2, 1), scale_factor=2).permute(0, 2, 1)
|
feats = F.interpolate(feats.permute(0, 2, 1), scale_factor=2).permute(0, 2, 1)
|
||||||
torch.cuda.synchronize()
|
torch.cuda.synchronize()
|
||||||
# p_len = min(feats.shape[1],10000,pitch.shape[0])#太大了爆显存
|
|
||||||
p_len = min(feats.shape[1], 12000) #
|
|
||||||
print(feats.shape)
|
print(feats.shape)
|
||||||
pitch, pitchf = self.get_f0(audio, self.f0_up_key)
|
if(self.if_f0==1):
|
||||||
p_len = min(feats.shape[1], 12000, pitch.shape[0]) # 太大了爆显存
|
pitch, pitchf = self.get_f0(audio, self.f0_up_key)
|
||||||
|
p_len = min(feats.shape[1], 13000, pitch.shape[0]) # 太大了爆显存
|
||||||
|
else:
|
||||||
|
pitch, pitchf = None, None
|
||||||
|
p_len = min(feats.shape[1], 13000) # 太大了爆显存
|
||||||
torch.cuda.synchronize()
|
torch.cuda.synchronize()
|
||||||
# print(feats.shape,pitch.shape)
|
# print(feats.shape,pitch.shape)
|
||||||
feats = feats[:, :p_len, :]
|
feats = feats[:, :p_len, :]
|
||||||
pitch = pitch[:p_len]
|
if(self.if_f0==1):
|
||||||
pitchf = pitchf[:p_len]
|
pitch = pitch[:p_len]
|
||||||
|
pitchf = pitchf[:p_len]
|
||||||
|
pitch = torch.LongTensor(pitch).unsqueeze(0).to(device)
|
||||||
|
pitchf = torch.FloatTensor(pitchf).unsqueeze(0).to(device)
|
||||||
p_len = torch.LongTensor([p_len]).to(device)
|
p_len = torch.LongTensor([p_len]).to(device)
|
||||||
pitch = torch.LongTensor(pitch).unsqueeze(0).to(device)
|
|
||||||
pitchf = torch.FloatTensor(pitchf).unsqueeze(0).to(device)
|
|
||||||
ii = 0 # sid
|
ii = 0 # sid
|
||||||
sid = torch.LongTensor([ii]).to(device)
|
sid = torch.LongTensor([ii]).to(device)
|
||||||
with torch.no_grad():
|
with torch.no_grad():
|
||||||
infered_audio = (
|
if(self.if_f0==1):
|
||||||
self.net_g.infer(feats, p_len, pitch, pitchf, sid)[0][0, 0]
|
infered_audio = (
|
||||||
.data.cpu()
|
self.net_g.infer(feats, p_len, pitch, pitchf, sid)[0][0, 0]
|
||||||
.float()
|
.data.cpu()
|
||||||
) # nsf
|
.float()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
infered_audio = (
|
||||||
|
self.net_g.infer(feats, p_len, sid)[0][0, 0]
|
||||||
|
.data.cpu()
|
||||||
|
.float()
|
||||||
|
)
|
||||||
torch.cuda.synchronize()
|
torch.cuda.synchronize()
|
||||||
return infered_audio
|
return infered_audio
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user