Skip to content

Commit

Permalink
Merge pull request #728 from AznamirWoW/refactor2
Browse files Browse the repository at this point in the history
corrected flags passed to Synthesizer and extract model functions
  • Loading branch information
blaisewf authored Sep 23, 2024
2 parents 895e064 + 342d915 commit d29e410
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 32 deletions.
43 changes: 13 additions & 30 deletions rvc/train/extract/preparing_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,30 @@ def generate_filelist(
feature_dir = os.path.join(model_path, f"{rvc_version}_extracted")

f0_dir, f0nsf_dir = None, None
if pitch_guidance:
f0_dir = os.path.join(model_path, "f0")
f0nsf_dir = os.path.join(model_path, "f0_voiced")
f0_dir = os.path.join(model_path, "f0")
f0nsf_dir = os.path.join(model_path, "f0_voiced")

gt_wavs_files = set(name.split(".")[0] for name in os.listdir(gt_wavs_dir))
feature_files = set(name.split(".")[0] for name in os.listdir(feature_dir))

if pitch_guidance:
f0_files = set(name.split(".")[0] for name in os.listdir(f0_dir))
f0nsf_files = set(name.split(".")[0] for name in os.listdir(f0nsf_dir))
names = gt_wavs_files & feature_files & f0_files & f0nsf_files
else:
names = gt_wavs_files & feature_files
f0_files = set(name.split(".")[0] for name in os.listdir(f0_dir))
f0nsf_files = set(name.split(".")[0] for name in os.listdir(f0nsf_dir))
names = gt_wavs_files & feature_files & f0_files & f0nsf_files

options = []
mute_base_path = os.path.join(current_directory, "logs", "mute")

for name in names:
if pitch_guidance:
options.append(
f"{gt_wavs_dir}/{name}.wav|{feature_dir}/{name}.npy|{f0_dir}/{name}.wav.npy|{f0nsf_dir}/{name}.wav.npy|0"
)
else:
options.append(f"{gt_wavs_dir}/{name}.wav|{feature_dir}/{name}.npy|0")
options.append(f"{gt_wavs_dir}/{name}.wav|{feature_dir}/{name}.npy|{f0_dir}/{name}.wav.npy|{f0nsf_dir}/{name}.wav.npy|0")

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

for _ in range(2):
if pitch_guidance:
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")
options.append(
f"{mute_audio_path}|{mute_feature_path}|{mute_f0_path}|{mute_f0nsf_path}|0"
)
else:
options.append(f"{mute_audio_path}|{mute_feature_path}|0")
# always adding two files
options.append(f"{mute_audio_path}|{mute_feature_path}|{mute_f0_path}|{mute_f0nsf_path}|0")
options.append(f"{mute_audio_path}|{mute_feature_path}|{mute_f0_path}|{mute_f0nsf_path}|0")

shuffle(options)

Expand Down
4 changes: 2 additions & 2 deletions rvc/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def run(
config.data.filter_length // 2 + 1,
config.train.segment_size // config.data.hop_length,
**config.model,
use_f0=pitch_guidance,
use_f0=pitch_guidance==True, # converting 1/0 to True/False
is_half=config.train.fp16_run and device.type == "cuda",
sr=sample_rate,
).to(device)
Expand Down Expand Up @@ -926,7 +926,7 @@ def train_and_evaluate(
extract_model(
ckpt=ckpt,
sr=sample_rate,
pitch_guidance=pitch_guidance,
pitch_guidance=pitch_guidance==True, # converting 1/0 to True/False,
name=model_name,
model_dir=m,
epoch=epoch,
Expand Down

0 comments on commit d29e410

Please sign in to comment.