From 71116f07e91f7874f755a75e1b37754b2086bd70 Mon Sep 17 00:00:00 2001 From: Roberts Slisans Date: Mon, 14 Aug 2023 11:21:15 +0300 Subject: [PATCH] Infer_batch_rvc improvements (#1003) * add model path for hubert * use os.path.join * do inference only if the script is called directly --- infer_batch_rvc.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/infer_batch_rvc.py b/infer_batch_rvc.py index 604853f..1f2b295 100644 --- a/infer_batch_rvc.py +++ b/infer_batch_rvc.py @@ -123,10 +123,10 @@ from scipy.io import wavfile hubert_model = None -def load_hubert(): +def load_hubert(hubert_model_path="hubert_base.pt"): global hubert_model models, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_task( - ["hubert_base.pt"], + [hubert_model_path], suffix="", ) hubert_model = models[0] @@ -203,13 +203,14 @@ def get_vc(model_path): # return {"visible": True,"maximum": n_spk, "__type__": "update"} -get_vc(model_path) -audios = os.listdir(input_path) -for file in tq.tqdm(audios): - if file.endswith(".wav"): - file_path = input_path + "/" + file - wav_opt = vc_single( - 0, file_path, f0up_key, None, f0method, index_path, index_rate - ) - out_path = opt_path + "/" + file - wavfile.write(out_path, tgt_sr, wav_opt) +if __name__ == "__main__": + get_vc(model_path) + audios = os.listdir(input_path) + for file in tq.tqdm(audios): + if file.endswith(".wav"): + file_path = os.path.join(input_path, file) + wav_opt = vc_single( + 0, file_path, f0up_key, None, f0method, index_path, index_rate + ) + out_path = os.path.join(opt_path, file) + wavfile.write(out_path, tgt_sr, wav_opt)