From c2cd30e4c07762dd06741360ff6d959baf4f63e4 Mon Sep 17 00:00:00 2001 From: Ftps Date: Sun, 19 Nov 2023 04:08:46 +0900 Subject: [PATCH] optimize vc-multi --- rvc/modules/vc/modules.py | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/rvc/modules/vc/modules.py b/rvc/modules/vc/modules.py index d9791fe..cf46f87 100644 --- a/rvc/modules/vc/modules.py +++ b/rvc/modules/vc/modules.py @@ -176,45 +176,40 @@ class VC: paths = [path.name for path in paths] infos = [] for path in paths: - info, opt = self.vc_single( + tgt_sr, audio_opt, _, info = self.vc_single( sid, - path, + Path(path), f0_up_key, - None, f0_method, - file_index, - file_index2, - # file_big_npy, + f0_file, + index_file, index_rate, filter_radius, resample_sr, rms_mix_rate, protect, + hubert_path, ) - if "Success" in info: + if info: try: - tgt_sr, audio_opt = opt - if format1 in ["wav", "flac"]: + if output_format in ["wav", "flac"]: sf.write( - "%s/%s.%s" - % (opt_root, os.path.basename(path), format1), + f"{opt_root}/{os.path.basename(path)}.{output_format}", audio_opt, tgt_sr, ) else: - path = "%s/%s.%s" % ( - opt_root, - os.path.basename(path), - format1, - ) with BytesIO() as wavf: sf.write(wavf, audio_opt, tgt_sr, format="wav") wavf.seek(0, 0) - with open(path, "wb") as outf: - wav2(wavf, outf, format1) - except: + with open( + f"{opt_root}/{os.path.basename(path)}.{output_format}", + "wb", + ) as outf: + wav2(wavf, outf, output_format) + except Exception: info += traceback.format_exc() - infos.append("%s->%s" % (os.path.basename(path), info)) + infos.append(f"{os.path.basename(path)}->{info}") yield "\n".join(infos) yield "\n".join(infos) except: