diff --git a/custom_nodes/rvc_nodes.py b/custom_nodes/rvc_nodes.py index d67fcca..9264b8c 100644 --- a/custom_nodes/rvc_nodes.py +++ b/custom_nodes/rvc_nodes.py @@ -66,7 +66,8 @@ class LoadPitchExtractionParams: "min": 0., #Minimum value "max": .5, #Maximum value "step": .01, #Slider's step - }) + }), + "crepe_hop_length": ("INT",{"default": 160, "min": 16, "max": 512, "step": 16}) }, } @@ -252,8 +253,13 @@ class RVCProcessDatasetNode: assert model_name, "Please provide a model name!" assert dataset, "Please upload a dataset!" - f0_method = pitch_extraction_params.get("f0_method") - cache_name = get_hash(model_name, dataset, period, overlap, max_volume, alpha, mute_ratio, f0_method) + f0_method = pitch_extraction_params.get("f0_method", "") + cached_params = [model_name, dataset, period, overlap, max_volume, alpha, mute_ratio, sr, f0_method] + crepe_hop_length = pitch_extraction_params.get("crepe_hop_length",160) + + if "crepe" in f0_method: cached_params.append(crepe_hop_length) + + cache_name = get_hash(*cached_params) model_log_dir = os.path.join(output_path,"logs",cache_name) os.makedirs(model_log_dir,exist_ok=True) @@ -268,7 +274,7 @@ class RVCProcessDatasetNode: print(preprocess_trainset(dataset_dir,SR_MAP[sr],n_threads,model_log_dir,period,overlap,max_volume,alpha)) - print(extract_features_trainset(hubert_model(), model_log_dir,n_p=n_threads,f0method=f0_method,device=device,if_f0=bool(f0_method),version="v2")) + print(extract_features_trainset(hubert_model(), model_log_dir,n_p=n_threads,f0method=f0_method,device=device,if_f0=bool(f0_method),version="v2",crepe_hop_length=crepe_hop_length)) gt_wavs_dir = os.path.join(model_log_dir,"0_gt_wavs") feature_dir = os.path.join(model_log_dir,"3_feature768") diff --git a/custom_nodes/utils.py b/custom_nodes/utils.py index dfb8df0..e660761 100644 --- a/custom_nodes/utils.py +++ b/custom_nodes/utils.py @@ -22,11 +22,11 @@ def increment_filename_no_overwrite(proposed_path): files = os.listdir(output_dir) files = filter(lambda f: os.path.isfile(os.path.join(output_dir, f)), files) files = filter(lambda f: f.startswith(filename), files) - files = filter(lambda f: f.endswith('.' + file_format), files) + files = filter(lambda f: f.endswith(file_format), files) file_numbers = [re.search(r'_(\d+)\.', f) for f in files] file_numbers = [int(f.group(1)) for f in file_numbers if f] this_file_number = max(file_numbers) + 1 if file_numbers else 1 - output_path = os.path.join(output_dir, f'{filename}_{this_file_number}.{file_format}') + output_path = os.path.join(output_dir, f'{filename}_{this_file_number}{file_format}') return output_path class MultipleTypeProxy(str): diff --git a/preprocessing_utils.py b/preprocessing_utils.py index 3d00120..f33710f 100644 --- a/preprocessing_utils.py +++ b/preprocessing_utils.py @@ -221,9 +221,9 @@ def preprocess_trainset(inp_root, sr, n_p, exp_dir, period=3.0, overlap=.3, max_ except Exception as e: return f"Failed to preprocess data: {e}" -def extract_features_trainset(hubert_model,exp_dir,n_p,f0method,device,version,if_f0): +def extract_features_trainset(hubert_model,exp_dir,n_p,f0method,device,version,if_f0,crepe_hop_length): try: - featureInput = FeatureInput(f0_method=f0method,exp_dir=exp_dir,device=device,version=version,if_f0=if_f0,model=hubert_model) + featureInput = FeatureInput(f0_method=f0method,exp_dir=exp_dir,device=device,version=version,if_f0=if_f0,model=hubert_model,hop_size=crepe_hop_length) paths = [] inp_root = os.path.join(exp_dir,"1_16k_wavs") opt_root1 = os.path.join(exp_dir,"2a_f0")