Skip to content

Commit

Permalink
Merge pull request IAHispano#692 from ShiromiyaG/delete-sliced
Browse files Browse the repository at this point in the history
Option to delete sliced audio folders
  • Loading branch information
blaisewf authored Sep 10, 2024
2 parents 6daac68 + f23cb70 commit 504bb9f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
11 changes: 11 additions & 0 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ def run_extract_script(
sample_rate: int,
embedder_model: str,
embedder_model_custom: str = None,
delete_sliced_audios: bool = True,
):

model_path = os.path.join(logs_path, model_name)
Expand All @@ -489,6 +490,7 @@ def run_extract_script(
sample_rate,
embedder_model,
embedder_model_custom,
delete_sliced_audios,
],
),
]
Expand Down Expand Up @@ -1329,6 +1331,14 @@ def parse_arguments():
help=embedder_model_custom_description,
default=None,
)
extract_parser.add_argument(
"--delete_sliced_folders",
type=lambda x: bool(strtobool(x)),
choices=[True, False],
help="Auto delete sliced audio folders after embedder process.",
default=True,
required=False,
)

# Parser for 'train' mode
train_parser = subparsers.add_parser("train", help="Train an RVC model.")
Expand Down Expand Up @@ -1736,6 +1746,7 @@ def main():
sample_rate=args.sample_rate,
embedder_model=args.embedder_model,
embedder_model_custom=args.embedder_model_custom,
delete_sliced_folders=args.delete_sliced_folders,
)
elif args.mode == "train":
run_train_script(
Expand Down
7 changes: 7 additions & 0 deletions rvc/train/extract/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import concurrent.futures
import multiprocessing as mp
import json
import shutil
from distutils.util import strtobool

# Zluda
if torch.cuda.is_available() and torch.cuda.get_device_name().endswith("[ZLUDA]"):
Expand Down Expand Up @@ -253,6 +255,7 @@ def run_embedding_extraction(
sample_rate = sys.argv[8]
embedder_model = sys.argv[9]
embedder_model_custom = sys.argv[10] if len(sys.argv) > 10 else None
delete_sliced_audios = strtobool(sys.argv[11]) if len(sys.argv) > 11 else True

# prep
wav_path = os.path.join(exp_dir, "sliced_audios_16k")
Expand Down Expand Up @@ -295,3 +298,7 @@ def run_embedding_extraction(
# Run Preparing Files
generate_config(version, sample_rate, exp_dir)
generate_filelist(pitch_guidance, exp_dir, version, sample_rate)

if delete_sliced_audios:
shutil.rmtree(os.path.join(exp_dir, "sliced_audios"), ignore_errors=True)
shutil.rmtree(os.path.join(exp_dir, "sliced_audios_16k"), ignore_errors=True)
26 changes: 18 additions & 8 deletions tabs/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,23 @@ def train_tab():
label="Upload .json", type="filepath", interactive=True
)
move_files_button = gr.Button("Move files to custom embedder folder")
pitch_guidance_extract = gr.Checkbox(
label=i18n("Pitch Guidance"),
info=i18n(
"By employing pitch guidance, it becomes feasible to mirror the intonation of the original voice, including its pitch. This feature is particularly valuable for singing and other scenarios where preserving the original melody or pitch pattern is essential."
),
value=True,
interactive=True,
)
with gr.Row():
pitch_guidance_extract = gr.Checkbox(
label=i18n("Pitch Guidance"),
info=i18n(
"By employing pitch guidance, it becomes feasible to mirror the intonation of the original voice, including its pitch. This feature is particularly valuable for singing and other scenarios where preserving the original melody or pitch pattern is essential."
),
value=True,
interactive=True,
)
delete_sliced_audio = gr.Checkbox(
label=i18n("Delete Sliced Audio"),
info=i18n(
"Delete the sliced audio folders after the embedder extraction process is completed."
),
value=True,
interactive=True,
)

with gr.Accordion(
i18n(
Expand Down Expand Up @@ -556,6 +565,7 @@ def train_tab():
sampling_rate,
embedder_model,
embedder_model_custom,
delete_sliced_audio,
],
outputs=[extract_output_info],
)
Expand Down

0 comments on commit 504bb9f

Please sign in to comment.