Infer_batch_rvc improvements (#1003)

* add model path for hubert

* use os.path.join

* do inference only if the script is called directly
This commit is contained in:
Roberts Slisans 2023-08-14 11:21:15 +03:00 committed by GitHub
parent 9bd0987815
commit 71116f07e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 12 deletions

View File

@ -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)