From 2310191bb5789fe8563dcfc8eea20b1fbd052e13 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 24 Sep 2024 10:36:12 +0000 Subject: [PATCH] chore(format): run black on main --- rvc/train/extract/extract.py | 8 +++++--- rvc/train/extract/preparing_files.py | 28 ++++++++++++++++++++-------- rvc/train/preprocess/preprocess.py | 26 ++++++++++++++++++++++---- tabs/inference/inference.py | 2 ++ 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/rvc/train/extract/extract.py b/rvc/train/extract/extract.py index 52639480..bae0f83f 100644 --- a/rvc/train/extract/extract.py +++ b/rvc/train/extract/extract.py @@ -272,9 +272,11 @@ def run_embedding_extraction( data = json.load(f) else: data = {} - data.update({ - "embedder_model": chosen_embedder_model, - }) + data.update( + { + "embedder_model": chosen_embedder_model, + } + ) with open(file_path, "w") as f: json.dump(data, f, indent=4) diff --git a/rvc/train/extract/preparing_files.py b/rvc/train/extract/preparing_files.py index 94a5d741..bc299104 100644 --- a/rvc/train/extract/preparing_files.py +++ b/rvc/train/extract/preparing_files.py @@ -39,17 +39,27 @@ def generate_filelist( sid = name.split("_")[0] if sid not in sids: sids.append(sid) - options.append(f"{gt_wavs_dir}/{name}.wav|{feature_dir}/{name}.npy|{f0_dir}/{name}.wav.npy|{f0nsf_dir}/{name}.wav.npy|{sid}") + options.append( + f"{gt_wavs_dir}/{name}.wav|{feature_dir}/{name}.npy|{f0_dir}/{name}.wav.npy|{f0nsf_dir}/{name}.wav.npy|{sid}" + ) - mute_audio_path = os.path.join(mute_base_path, "sliced_audios", f"mute{sample_rate}.wav") - mute_feature_path = os.path.join(mute_base_path, f"{rvc_version}_extracted", "mute.npy") + mute_audio_path = os.path.join( + mute_base_path, "sliced_audios", f"mute{sample_rate}.wav" + ) + mute_feature_path = os.path.join( + mute_base_path, f"{rvc_version}_extracted", "mute.npy" + ) mute_f0_path = os.path.join(mute_base_path, "f0", "mute.wav.npy") mute_f0nsf_path = os.path.join(mute_base_path, "f0_voiced", "mute.wav.npy") # always adding two files for sid in sids: - options.append(f"{mute_audio_path}|{mute_feature_path}|{mute_f0_path}|{mute_f0nsf_path}|{sid}") - options.append(f"{mute_audio_path}|{mute_feature_path}|{mute_f0_path}|{mute_f0nsf_path}|{sid}") + options.append( + f"{mute_audio_path}|{mute_feature_path}|{mute_f0_path}|{mute_f0nsf_path}|{sid}" + ) + options.append( + f"{mute_audio_path}|{mute_feature_path}|{mute_f0_path}|{mute_f0nsf_path}|{sid}" + ) file_path = os.path.join(model_path, "model_info.json") if os.path.exists(file_path): @@ -57,9 +67,11 @@ def generate_filelist( data = json.load(f) else: data = {} - data.update({ - "speakers_id": len(sids), - }) + data.update( + { + "speakers_id": len(sids), + } + ) with open(file_path, "w") as f: json.dump(data, f, indent=4) diff --git a/rvc/train/preprocess/preprocess.py b/rvc/train/preprocess/preprocess.py index 8d848210..d27f623f 100644 --- a/rvc/train/preprocess/preprocess.py +++ b/rvc/train/preprocess/preprocess.py @@ -67,7 +67,7 @@ def process_audio_segment( sid: int, idx0: int, idx1: int, - process_effects: bool + process_effects: bool, ): normalized_audio = ( self._normalize_audio(audio_segment) if process_effects else audio_segment @@ -178,6 +178,7 @@ def process_audio_wrapper(args): reduction_strength, ) + def preprocess_training_set( input_root: str, sr: int, @@ -204,13 +205,30 @@ def preprocess_training_set( files.append((os.path.join(root, f), idx, sid)) idx += 1 except ValueError: - print(f"Speaker ID folder is expected to be integer, got \"{os.path.basename(root)}\" instead.") + print( + f'Speaker ID folder is expected to be integer, got "{os.path.basename(root)}" instead.' + ) # print(f"Number of files: {len(files)}") audio_length = [] with tqdm(total=len(files)) as pbar: - with concurrent.futures.ProcessPoolExecutor(max_workers=num_processes) as executor: - futures = [executor.submit(process_audio_wrapper, (pp, file, cut_preprocess, process_effects, noise_reduction, reduction_strength,)) for file in files] + with concurrent.futures.ProcessPoolExecutor( + max_workers=num_processes + ) as executor: + futures = [ + executor.submit( + process_audio_wrapper, + ( + pp, + file, + cut_preprocess, + process_effects, + noise_reduction, + reduction_strength, + ), + ) + for file in files + ] for future in concurrent.futures.as_completed(futures): audio_length.append(future.result()) pbar.update(1) diff --git a/tabs/inference/inference.py b/tabs/inference/inference.py index 9ed15b6f..77a75af8 100644 --- a/tabs/inference/inference.py +++ b/tabs/inference/inference.py @@ -299,11 +299,13 @@ def refresh_embedders_folders(): ] return custom_embedders + def get_speakers_id(model): model_data = torch.load(model, map_location="cpu") speakers_id = model_data.get("speakers_id", 0) return list(range(speakers_id + 1)) + # Inference tab def inference_tab(): default_weight = names[0] if names else None