mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2025-01-18 04:10:08 +08:00
Format code (#455)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
6f1bc7d683
commit
52c97ed464
15
MDXNet.py
15
MDXNet.py
@ -206,25 +206,28 @@ class Predictor:
|
|||||||
mix = mix.T
|
mix = mix.T
|
||||||
sources = self.demix(mix.T)
|
sources = self.demix(mix.T)
|
||||||
opt = sources[0].T
|
opt = sources[0].T
|
||||||
if(format in ["wav", "flac"]):
|
if format in ["wav", "flac"]:
|
||||||
sf.write("%s/%s_main_vocal.%s" % (vocal_root, basename, format), mix - opt, rate)
|
sf.write(
|
||||||
|
"%s/%s_main_vocal.%s" % (vocal_root, basename, format), mix - opt, rate
|
||||||
|
)
|
||||||
sf.write("%s/%s_others.%s" % (others_root, basename, format), opt, rate)
|
sf.write("%s/%s_others.%s" % (others_root, basename, format), opt, rate)
|
||||||
else:
|
else:
|
||||||
path_vocal="%s/%s_main_vocal.wav" % (vocal_root, basename)
|
path_vocal = "%s/%s_main_vocal.wav" % (vocal_root, basename)
|
||||||
path_other="%s/%s_others.wav" % (others_root, basename)
|
path_other = "%s/%s_others.wav" % (others_root, basename)
|
||||||
sf.write(path_vocal, mix - opt, rate)
|
sf.write(path_vocal, mix - opt, rate)
|
||||||
sf.write(path_other, opt, rate)
|
sf.write(path_other, opt, rate)
|
||||||
if (os.path.exists(path_vocal)):
|
if os.path.exists(path_vocal):
|
||||||
os.system(
|
os.system(
|
||||||
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
||||||
% (path_vocal, path_vocal[:-4] + ".%s" % format)
|
% (path_vocal, path_vocal[:-4] + ".%s" % format)
|
||||||
)
|
)
|
||||||
if (os.path.exists(path_other)):
|
if os.path.exists(path_other):
|
||||||
os.system(
|
os.system(
|
||||||
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
||||||
% (path_other, path_other[:-4] + ".%s" % format)
|
% (path_other, path_other[:-4] + ".%s" % format)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class MDXNetDereverb:
|
class MDXNetDereverb:
|
||||||
def __init__(self, chunks):
|
def __init__(self, chunks):
|
||||||
self.onnx = "uvr5_weights/onnx_dereverb_By_FoxJoy"
|
self.onnx = "uvr5_weights/onnx_dereverb_By_FoxJoy"
|
||||||
|
8
gui.py
8
gui.py
@ -584,10 +584,14 @@ class GUI:
|
|||||||
if d["max_output_channels"] > 0
|
if d["max_output_channels"] > 0
|
||||||
]
|
]
|
||||||
input_devices_indices = [
|
input_devices_indices = [
|
||||||
d["index"] if "index" in d else d["name"] for d in devices if d["max_input_channels"] > 0
|
d["index"] if "index" in d else d["name"]
|
||||||
|
for d in devices
|
||||||
|
if d["max_input_channels"] > 0
|
||||||
]
|
]
|
||||||
output_devices_indices = [
|
output_devices_indices = [
|
||||||
d["index"] if "index" in d else d["name"] for d in devices if d["max_output_channels"] > 0
|
d["index"] if "index" in d else d["name"]
|
||||||
|
for d in devices
|
||||||
|
if d["max_output_channels"] > 0
|
||||||
]
|
]
|
||||||
return (
|
return (
|
||||||
input_devices,
|
input_devices,
|
||||||
|
@ -272,20 +272,20 @@ def vc_multi(
|
|||||||
if "Success" in info:
|
if "Success" in info:
|
||||||
try:
|
try:
|
||||||
tgt_sr, audio_opt = opt
|
tgt_sr, audio_opt = opt
|
||||||
if (format1 in ["wav", "flac"]):
|
if format1 in ["wav", "flac"]:
|
||||||
sf.write(
|
sf.write(
|
||||||
"%s/%s.%s" % (opt_root, os.path.basename(path), format1),
|
"%s/%s.%s" % (opt_root, os.path.basename(path), format1),
|
||||||
audio_opt,
|
audio_opt,
|
||||||
tgt_sr,
|
tgt_sr,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
path="%s/%s.wav" % (opt_root, os.path.basename(path))
|
path = "%s/%s.wav" % (opt_root, os.path.basename(path))
|
||||||
sf.write(
|
sf.write(
|
||||||
path,
|
path,
|
||||||
audio_opt,
|
audio_opt,
|
||||||
tgt_sr,
|
tgt_sr,
|
||||||
)
|
)
|
||||||
if (os.path.exists(path)):
|
if os.path.exists(path):
|
||||||
os.system(
|
os.system(
|
||||||
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
||||||
% (path, path[:-4] + ".%s" % format1)
|
% (path, path[:-4] + ".%s" % format1)
|
||||||
|
@ -123,7 +123,7 @@ class _audio_pre_:
|
|||||||
else:
|
else:
|
||||||
wav_instrument = spec_utils.cmb_spectrogram_to_wave(y_spec_m, self.mp)
|
wav_instrument = spec_utils.cmb_spectrogram_to_wave(y_spec_m, self.mp)
|
||||||
print("%s instruments done" % name)
|
print("%s instruments done" % name)
|
||||||
if(format in ["wav","flac"]):
|
if format in ["wav", "flac"]:
|
||||||
sf.write(
|
sf.write(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
ins_root,
|
ins_root,
|
||||||
@ -133,18 +133,18 @@ class _audio_pre_:
|
|||||||
self.mp.param["sr"],
|
self.mp.param["sr"],
|
||||||
) #
|
) #
|
||||||
else:
|
else:
|
||||||
path=os.path.join(
|
path = os.path.join(
|
||||||
ins_root, "instrument_{}_{}.wav".format(name, self.data["agg"])
|
ins_root, "instrument_{}_{}.wav".format(name, self.data["agg"])
|
||||||
)
|
)
|
||||||
sf.write(
|
sf.write(
|
||||||
path ,
|
path,
|
||||||
(np.array(wav_instrument) * 32768).astype("int16"),
|
(np.array(wav_instrument) * 32768).astype("int16"),
|
||||||
self.mp.param["sr"],
|
self.mp.param["sr"],
|
||||||
)
|
)
|
||||||
if(os.path.exists(path)):
|
if os.path.exists(path):
|
||||||
os.system(
|
os.system(
|
||||||
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
||||||
% (path, path[:-4]+".%s"%format)
|
% (path, path[:-4] + ".%s" % format)
|
||||||
)
|
)
|
||||||
if vocal_root is not None:
|
if vocal_root is not None:
|
||||||
if self.data["high_end_process"].startswith("mirroring"):
|
if self.data["high_end_process"].startswith("mirroring"):
|
||||||
@ -157,29 +157,31 @@ class _audio_pre_:
|
|||||||
else:
|
else:
|
||||||
wav_vocals = spec_utils.cmb_spectrogram_to_wave(v_spec_m, self.mp)
|
wav_vocals = spec_utils.cmb_spectrogram_to_wave(v_spec_m, self.mp)
|
||||||
print("%s vocals done" % name)
|
print("%s vocals done" % name)
|
||||||
if(format in ["wav","flac"]):
|
if format in ["wav", "flac"]:
|
||||||
sf.write(
|
sf.write(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
vocal_root, "vocal_{}_{}.{}".format(name, self.data["agg"], format)
|
vocal_root,
|
||||||
|
"vocal_{}_{}.{}".format(name, self.data["agg"], format),
|
||||||
),
|
),
|
||||||
(np.array(wav_vocals) * 32768).astype("int16"),
|
(np.array(wav_vocals) * 32768).astype("int16"),
|
||||||
self.mp.param["sr"],
|
self.mp.param["sr"],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
path=os.path.join(
|
path = os.path.join(
|
||||||
vocal_root, "vocal_{}_{}.wav".format(name, self.data["agg"])
|
vocal_root, "vocal_{}_{}.wav".format(name, self.data["agg"])
|
||||||
)
|
)
|
||||||
sf.write(
|
sf.write(
|
||||||
path ,
|
path,
|
||||||
(np.array(wav_vocals) * 32768).astype("int16"),
|
(np.array(wav_vocals) * 32768).astype("int16"),
|
||||||
self.mp.param["sr"],
|
self.mp.param["sr"],
|
||||||
)
|
)
|
||||||
if(os.path.exists(path)):
|
if os.path.exists(path):
|
||||||
os.system(
|
os.system(
|
||||||
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
||||||
% (path, path[:-4]+".%s"%format)
|
% (path, path[:-4] + ".%s" % format)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class _audio_pre_new:
|
class _audio_pre_new:
|
||||||
def __init__(self, agg, model_path, device, is_half):
|
def __init__(self, agg, model_path, device, is_half):
|
||||||
self.model_path = model_path
|
self.model_path = model_path
|
||||||
@ -288,7 +290,7 @@ class _audio_pre_new:
|
|||||||
else:
|
else:
|
||||||
wav_instrument = spec_utils.cmb_spectrogram_to_wave(y_spec_m, self.mp)
|
wav_instrument = spec_utils.cmb_spectrogram_to_wave(y_spec_m, self.mp)
|
||||||
print("%s instruments done" % name)
|
print("%s instruments done" % name)
|
||||||
if(format in ["wav","flac"]):
|
if format in ["wav", "flac"]:
|
||||||
sf.write(
|
sf.write(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
ins_root,
|
ins_root,
|
||||||
@ -298,18 +300,18 @@ class _audio_pre_new:
|
|||||||
self.mp.param["sr"],
|
self.mp.param["sr"],
|
||||||
) #
|
) #
|
||||||
else:
|
else:
|
||||||
path=os.path.join(
|
path = os.path.join(
|
||||||
ins_root, "instrument_{}_{}.wav".format(name, self.data["agg"])
|
ins_root, "instrument_{}_{}.wav".format(name, self.data["agg"])
|
||||||
)
|
)
|
||||||
sf.write(
|
sf.write(
|
||||||
path ,
|
path,
|
||||||
(np.array(wav_instrument) * 32768).astype("int16"),
|
(np.array(wav_instrument) * 32768).astype("int16"),
|
||||||
self.mp.param["sr"],
|
self.mp.param["sr"],
|
||||||
)
|
)
|
||||||
if(os.path.exists(path)):
|
if os.path.exists(path):
|
||||||
os.system(
|
os.system(
|
||||||
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
||||||
% (path, path[:-4]+".%s"%format)
|
% (path, path[:-4] + ".%s" % format)
|
||||||
)
|
)
|
||||||
if vocal_root is not None:
|
if vocal_root is not None:
|
||||||
if self.data["high_end_process"].startswith("mirroring"):
|
if self.data["high_end_process"].startswith("mirroring"):
|
||||||
@ -322,29 +324,31 @@ class _audio_pre_new:
|
|||||||
else:
|
else:
|
||||||
wav_vocals = spec_utils.cmb_spectrogram_to_wave(v_spec_m, self.mp)
|
wav_vocals = spec_utils.cmb_spectrogram_to_wave(v_spec_m, self.mp)
|
||||||
print("%s vocals done" % name)
|
print("%s vocals done" % name)
|
||||||
if(format in ["wav","flac"]):
|
if format in ["wav", "flac"]:
|
||||||
sf.write(
|
sf.write(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
vocal_root, "vocal_{}_{}.{}".format(name, self.data["agg"], format)
|
vocal_root,
|
||||||
|
"vocal_{}_{}.{}".format(name, self.data["agg"], format),
|
||||||
),
|
),
|
||||||
(np.array(wav_vocals) * 32768).astype("int16"),
|
(np.array(wav_vocals) * 32768).astype("int16"),
|
||||||
self.mp.param["sr"],
|
self.mp.param["sr"],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
path=os.path.join(
|
path = os.path.join(
|
||||||
vocal_root, "vocal_{}_{}.wav".format(name, self.data["agg"])
|
vocal_root, "vocal_{}_{}.wav".format(name, self.data["agg"])
|
||||||
)
|
)
|
||||||
sf.write(
|
sf.write(
|
||||||
path ,
|
path,
|
||||||
(np.array(wav_vocals) * 32768).astype("int16"),
|
(np.array(wav_vocals) * 32768).astype("int16"),
|
||||||
self.mp.param["sr"],
|
self.mp.param["sr"],
|
||||||
)
|
)
|
||||||
if(os.path.exists(path)):
|
if os.path.exists(path):
|
||||||
os.system(
|
os.system(
|
||||||
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
"ffmpeg -i %s -vn %s -q:a 2 -y"
|
||||||
% (path, path[:-4]+".%s"%format)
|
% (path, path[:-4] + ".%s" % format)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
device = "cuda"
|
device = "cuda"
|
||||||
is_half = True
|
is_half = True
|
||||||
|
@ -8,7 +8,7 @@ from i18n import I18nAuto
|
|||||||
i18n = I18nAuto()
|
i18n = I18nAuto()
|
||||||
|
|
||||||
|
|
||||||
def savee(ckpt, sr, if_f0, name, epoch, version,hps):
|
def savee(ckpt, sr, if_f0, name, epoch, version, hps):
|
||||||
try:
|
try:
|
||||||
opt = OrderedDict()
|
opt = OrderedDict()
|
||||||
opt["weight"] = {}
|
opt["weight"] = {}
|
||||||
@ -16,8 +16,8 @@ def savee(ckpt, sr, if_f0, name, epoch, version,hps):
|
|||||||
if "enc_q" in key:
|
if "enc_q" in key:
|
||||||
continue
|
continue
|
||||||
opt["weight"][key] = ckpt[key].half()
|
opt["weight"][key] = ckpt[key].half()
|
||||||
opt["config"]=[
|
opt["config"] = [
|
||||||
hpt.data.filter_length//2+1,
|
hpt.data.filter_length // 2 + 1,
|
||||||
32,
|
32,
|
||||||
hpt.model.inter_channels,
|
hpt.model.inter_channels,
|
||||||
hpt.model.hidden_channels,
|
hpt.model.hidden_channels,
|
||||||
@ -34,7 +34,7 @@ def savee(ckpt, sr, if_f0, name, epoch, version,hps):
|
|||||||
hpt.model.upsample_kernel_sizes,
|
hpt.model.upsample_kernel_sizes,
|
||||||
hpt.model.spk_embed_dim,
|
hpt.model.spk_embed_dim,
|
||||||
hpt.model.gin_channels,
|
hpt.model.gin_channels,
|
||||||
hpt.data.sampling_rate
|
hpt.data.sampling_rate,
|
||||||
]
|
]
|
||||||
opt["info"] = "%sepoch" % epoch
|
opt["info"] = "%sepoch" % epoch
|
||||||
opt["sr"] = sr
|
opt["sr"] = sr
|
||||||
|
@ -559,7 +559,8 @@ def train_and_evaluate(
|
|||||||
hps.if_f0,
|
hps.if_f0,
|
||||||
hps.name + "_e%s" % epoch,
|
hps.name + "_e%s" % epoch,
|
||||||
epoch,
|
epoch,
|
||||||
hps.version,hps
|
hps.version,
|
||||||
|
hps,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -575,7 +576,11 @@ def train_and_evaluate(
|
|||||||
ckpt = net_g.state_dict()
|
ckpt = net_g.state_dict()
|
||||||
logger.info(
|
logger.info(
|
||||||
"saving final ckpt:%s"
|
"saving final ckpt:%s"
|
||||||
% (savee(ckpt, hps.sample_rate, hps.if_f0, hps.name, epoch, hps.version,hps))
|
% (
|
||||||
|
savee(
|
||||||
|
ckpt, hps.sample_rate, hps.if_f0, hps.name, epoch, hps.version, hps
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
sleep(1)
|
sleep(1)
|
||||||
os._exit(2333333)
|
os._exit(2333333)
|
||||||
|
Loading…
Reference in New Issue
Block a user