Format code (#455)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
github-actions[bot] 2023-06-06 14:35:35 +00:00 committed by GitHub
parent 6f1bc7d683
commit 52c97ed464
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 47 deletions

View File

@ -206,25 +206,28 @@ class Predictor:
mix = mix.T
sources = self.demix(mix.T)
opt = sources[0].T
if(format in ["wav", "flac"]):
sf.write("%s/%s_main_vocal.%s" % (vocal_root, basename, format), mix - opt, rate)
if format in ["wav", "flac"]:
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)
else:
path_vocal = "%s/%s_main_vocal.wav" % (vocal_root, basename)
path_other = "%s/%s_others.wav" % (others_root, basename)
sf.write(path_vocal, mix - opt, rate)
sf.write(path_other, opt, rate)
if (os.path.exists(path_vocal)):
if os.path.exists(path_vocal):
os.system(
"ffmpeg -i %s -vn %s -q:a 2 -y"
% (path_vocal, path_vocal[:-4] + ".%s" % format)
)
if (os.path.exists(path_other)):
if os.path.exists(path_other):
os.system(
"ffmpeg -i %s -vn %s -q:a 2 -y"
% (path_other, path_other[:-4] + ".%s" % format)
)
class MDXNetDereverb:
def __init__(self, chunks):
self.onnx = "uvr5_weights/onnx_dereverb_By_FoxJoy"

8
gui.py
View File

@ -584,10 +584,14 @@ class GUI:
if d["max_output_channels"] > 0
]
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 = [
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 (
input_devices,

View File

@ -272,7 +272,7 @@ def vc_multi(
if "Success" in info:
try:
tgt_sr, audio_opt = opt
if (format1 in ["wav", "flac"]):
if format1 in ["wav", "flac"]:
sf.write(
"%s/%s.%s" % (opt_root, os.path.basename(path), format1),
audio_opt,
@ -285,7 +285,7 @@ def vc_multi(
audio_opt,
tgt_sr,
)
if (os.path.exists(path)):
if os.path.exists(path):
os.system(
"ffmpeg -i %s -vn %s -q:a 2 -y"
% (path, path[:-4] + ".%s" % format1)

View File

@ -123,7 +123,7 @@ class _audio_pre_:
else:
wav_instrument = spec_utils.cmb_spectrogram_to_wave(y_spec_m, self.mp)
print("%s instruments done" % name)
if(format in ["wav","flac"]):
if format in ["wav", "flac"]:
sf.write(
os.path.join(
ins_root,
@ -141,7 +141,7 @@ class _audio_pre_:
(np.array(wav_instrument) * 32768).astype("int16"),
self.mp.param["sr"],
)
if(os.path.exists(path)):
if os.path.exists(path):
os.system(
"ffmpeg -i %s -vn %s -q:a 2 -y"
% (path, path[:-4] + ".%s" % format)
@ -157,10 +157,11 @@ class _audio_pre_:
else:
wav_vocals = spec_utils.cmb_spectrogram_to_wave(v_spec_m, self.mp)
print("%s vocals done" % name)
if(format in ["wav","flac"]):
if format in ["wav", "flac"]:
sf.write(
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"),
self.mp.param["sr"],
@ -174,12 +175,13 @@ class _audio_pre_:
(np.array(wav_vocals) * 32768).astype("int16"),
self.mp.param["sr"],
)
if(os.path.exists(path)):
if os.path.exists(path):
os.system(
"ffmpeg -i %s -vn %s -q:a 2 -y"
% (path, path[:-4] + ".%s" % format)
)
class _audio_pre_new:
def __init__(self, agg, model_path, device, is_half):
self.model_path = model_path
@ -288,7 +290,7 @@ class _audio_pre_new:
else:
wav_instrument = spec_utils.cmb_spectrogram_to_wave(y_spec_m, self.mp)
print("%s instruments done" % name)
if(format in ["wav","flac"]):
if format in ["wav", "flac"]:
sf.write(
os.path.join(
ins_root,
@ -306,7 +308,7 @@ class _audio_pre_new:
(np.array(wav_instrument) * 32768).astype("int16"),
self.mp.param["sr"],
)
if(os.path.exists(path)):
if os.path.exists(path):
os.system(
"ffmpeg -i %s -vn %s -q:a 2 -y"
% (path, path[:-4] + ".%s" % format)
@ -322,10 +324,11 @@ class _audio_pre_new:
else:
wav_vocals = spec_utils.cmb_spectrogram_to_wave(v_spec_m, self.mp)
print("%s vocals done" % name)
if(format in ["wav","flac"]):
if format in ["wav", "flac"]:
sf.write(
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"),
self.mp.param["sr"],
@ -339,12 +342,13 @@ class _audio_pre_new:
(np.array(wav_vocals) * 32768).astype("int16"),
self.mp.param["sr"],
)
if(os.path.exists(path)):
if os.path.exists(path):
os.system(
"ffmpeg -i %s -vn %s -q:a 2 -y"
% (path, path[:-4] + ".%s" % format)
)
if __name__ == "__main__":
device = "cuda"
is_half = True

View File

@ -34,7 +34,7 @@ def savee(ckpt, sr, if_f0, name, epoch, version,hps):
hpt.model.upsample_kernel_sizes,
hpt.model.spk_embed_dim,
hpt.model.gin_channels,
hpt.data.sampling_rate
hpt.data.sampling_rate,
]
opt["info"] = "%sepoch" % epoch
opt["sr"] = sr

View File

@ -559,7 +559,8 @@ def train_and_evaluate(
hps.if_f0,
hps.name + "_e%s" % epoch,
epoch,
hps.version,hps
hps.version,
hps,
),
)
)
@ -575,7 +576,11 @@ def train_and_evaluate(
ckpt = net_g.state_dict()
logger.info(
"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)
os._exit(2333333)