Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(format): run black on main #736

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions rvc/train/extract/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
28 changes: 20 additions & 8 deletions rvc/train/extract/preparing_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,39 @@ 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):
with open(file_path, "r") as f:
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)

Expand Down
26 changes: 22 additions & 4 deletions rvc/train/preprocess/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -178,6 +178,7 @@ def process_audio_wrapper(args):
reduction_strength,
)


def preprocess_training_set(
input_root: str,
sr: int,
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tabs/inference/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down