Update myinfer.py
#25
by
secretguest
- opened
- myinfer.py +25 -17
myinfer.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
'''
|
| 2 |
-
runtime\python.exe myinfer.py 0 "
|
| 3 |
'''
|
|
|
|
| 4 |
import os,sys,pdb,torch
|
| 5 |
now_dir = os.getcwd()
|
| 6 |
sys.path.append(now_dir)
|
|
@@ -86,21 +87,28 @@ class Config:
|
|
| 86 |
|
| 87 |
return x_pad, x_query, x_center, x_max
|
| 88 |
|
| 89 |
-
f0up_key=sys.argv[1]
|
| 90 |
-
input_path=sys.argv[2]
|
| 91 |
-
index_path=sys.argv[3]
|
| 92 |
-
f0method=sys.argv[4]
|
| 93 |
-
opt_path=sys.argv[5]
|
| 94 |
-
model_path=sys.argv[6]
|
| 95 |
-
index_rate=float(sys.argv[7])
|
| 96 |
-
device=sys.argv[8]
|
| 97 |
-
is_half=bool(sys.argv[9])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
print(sys.argv)
|
| 99 |
config=Config(device,is_half)
|
| 100 |
now_dir=os.getcwd()
|
| 101 |
sys.path.append(now_dir)
|
| 102 |
from vc_infer_pipeline import VC
|
| 103 |
-
from lib.infer_pack.models import
|
| 104 |
from lib.audio import load_audio
|
| 105 |
from fairseq import checkpoint_utils
|
| 106 |
from scipy.io import wavfile
|
|
@@ -115,8 +123,8 @@ def load_hubert():
|
|
| 115 |
else:hubert_model = hubert_model.float()
|
| 116 |
hubert_model.eval()
|
| 117 |
|
| 118 |
-
def vc_single(sid,input_audio,f0_up_key,f0_file,f0_method,file_index,index_rate):
|
| 119 |
-
global
|
| 120 |
if input_audio is None:return "You need to upload an audio", None
|
| 121 |
f0_up_key = int(f0_up_key)
|
| 122 |
audio=load_audio(input_audio,16000)
|
|
@@ -124,7 +132,7 @@ def vc_single(sid,input_audio,f0_up_key,f0_file,f0_method,file_index,index_rate)
|
|
| 124 |
if(hubert_model==None):load_hubert()
|
| 125 |
if_f0 = cpt.get("f0", 1)
|
| 126 |
# audio_opt=vc.pipeline(hubert_model,net_g,sid,audio,times,f0_up_key,f0_method,file_index,file_big_npy,index_rate,if_f0,f0_file=f0_file)
|
| 127 |
-
audio_opt=vc.pipeline(hubert_model,net_g,sid,audio,times,f0_up_key,f0_method,
|
| 128 |
print(times)
|
| 129 |
return audio_opt
|
| 130 |
|
|
@@ -137,9 +145,9 @@ def get_vc(model_path):
|
|
| 137 |
cpt["config"][-3]=cpt["weight"]["emb_g.weight"].shape[0]#n_spk
|
| 138 |
if_f0=cpt.get("f0",1)
|
| 139 |
if(if_f0==1):
|
| 140 |
-
net_g =
|
| 141 |
else:
|
| 142 |
-
net_g =
|
| 143 |
del net_g.enc_q
|
| 144 |
print(net_g.load_state_dict(cpt["weight"], strict=False)) # 不加这一行清不干净,真奇葩
|
| 145 |
net_g.eval().to(device)
|
|
@@ -151,6 +159,6 @@ def get_vc(model_path):
|
|
| 151 |
|
| 152 |
|
| 153 |
get_vc(model_path)
|
| 154 |
-
wav_opt=vc_single(0,input_path,f0up_key,None,f0method,index_path,index_rate)
|
| 155 |
wavfile.write(opt_path, tgt_sr, wav_opt)
|
| 156 |
|
|
|
|
| 1 |
'''
|
| 2 |
+
runtime\python.exe myinfer.py 0 "C:\ YOUR PATH FOR THE ROOT (RVC0813Nvidia)\INPUTS_VOCAL\vocal.wav" "C:\ YOUR PATH FOR THE ROOT (RVC0813Nvidia)\logs\Hagrid.index" harvest "C:\ YOUR PATH FOR THE ROOT (RVC0813Nvidia)\INPUTS_VOCAL\test.wav" "C:\ YOUR PATH FOR THE ROOT (RVC0813Nvidia)\weights\HagridFR.pth" 0.6 cuda:0 True 5 44100 44100 1.0 1.0 True
|
| 3 |
'''
|
| 4 |
+
|
| 5 |
import os,sys,pdb,torch
|
| 6 |
now_dir = os.getcwd()
|
| 7 |
sys.path.append(now_dir)
|
|
|
|
| 87 |
|
| 88 |
return x_pad, x_query, x_center, x_max
|
| 89 |
|
| 90 |
+
f0up_key=sys.argv[1]
|
| 91 |
+
input_path = sys.argv[2]
|
| 92 |
+
index_path = sys.argv[3]
|
| 93 |
+
f0method = sys.argv[4]
|
| 94 |
+
opt_path = sys.argv[5]
|
| 95 |
+
model_path = sys.argv[6]
|
| 96 |
+
index_rate = float(sys.argv[7])
|
| 97 |
+
device = sys.argv[8]
|
| 98 |
+
is_half = bool(sys.argv[9])
|
| 99 |
+
filter_radius = int(sys.argv[10])
|
| 100 |
+
tgt_sr = int(sys.argv[11])
|
| 101 |
+
resample_sr = int(sys.argv[12])
|
| 102 |
+
rms_mix_rate = float(sys.argv[13])
|
| 103 |
+
version = sys.argv[14]
|
| 104 |
+
protect = sys.argv[15].lower() == 'false'
|
| 105 |
+
|
| 106 |
print(sys.argv)
|
| 107 |
config=Config(device,is_half)
|
| 108 |
now_dir=os.getcwd()
|
| 109 |
sys.path.append(now_dir)
|
| 110 |
from vc_infer_pipeline import VC
|
| 111 |
+
from lib.infer_pack.models import SynthesizerTrnMs768NSFsid, SynthesizerTrnMs768NSFsid_nono
|
| 112 |
from lib.audio import load_audio
|
| 113 |
from fairseq import checkpoint_utils
|
| 114 |
from scipy.io import wavfile
|
|
|
|
| 123 |
else:hubert_model = hubert_model.float()
|
| 124 |
hubert_model.eval()
|
| 125 |
|
| 126 |
+
def vc_single(sid, input_audio, f0_up_key, f0_file, f0_method, file_index, index_rate, filter_radius, tgt_sr, resample_sr, rms_mix_rate, version, protect):
|
| 127 |
+
global net_g, vc, hubert_model
|
| 128 |
if input_audio is None:return "You need to upload an audio", None
|
| 129 |
f0_up_key = int(f0_up_key)
|
| 130 |
audio=load_audio(input_audio,16000)
|
|
|
|
| 132 |
if(hubert_model==None):load_hubert()
|
| 133 |
if_f0 = cpt.get("f0", 1)
|
| 134 |
# audio_opt=vc.pipeline(hubert_model,net_g,sid,audio,times,f0_up_key,f0_method,file_index,file_big_npy,index_rate,if_f0,f0_file=f0_file)
|
| 135 |
+
audio_opt = vc.pipeline(hubert_model, net_g, sid, audio, input_path, times, f0_up_key, f0_method, index_path, index_rate, if_f0, filter_radius, tgt_sr, resample_sr, rms_mix_rate, version, protect, f0_file=f0_file)
|
| 136 |
print(times)
|
| 137 |
return audio_opt
|
| 138 |
|
|
|
|
| 145 |
cpt["config"][-3]=cpt["weight"]["emb_g.weight"].shape[0]#n_spk
|
| 146 |
if_f0=cpt.get("f0",1)
|
| 147 |
if(if_f0==1):
|
| 148 |
+
net_g = SynthesizerTrnMs768NSFsid(*cpt["config"], is_half=is_half)
|
| 149 |
else:
|
| 150 |
+
net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
|
| 151 |
del net_g.enc_q
|
| 152 |
print(net_g.load_state_dict(cpt["weight"], strict=False)) # 不加这一行清不干净,真奇葩
|
| 153 |
net_g.eval().to(device)
|
|
|
|
| 159 |
|
| 160 |
|
| 161 |
get_vc(model_path)
|
| 162 |
+
wav_opt = vc_single(0, input_path, f0up_key, None, f0method, index_path, index_rate, filter_radius, tgt_sr, resample_sr, rms_mix_rate, version, protect)
|
| 163 |
wavfile.write(opt_path, tgt_sr, wav_opt)
|
| 164 |
|