From fe0584baea8ce7af1fdda1e0c99ed6d5dd18a083 Mon Sep 17 00:00:00 2001 From: Blaise <133521603+blaise-tk@users.noreply.github.com> Date: Tue, 12 Dec 2023 22:01:09 +0100 Subject: [PATCH] duplicated code (idk why) --- main.py | 156 -------------------------------------------------------- 1 file changed, 156 deletions(-) diff --git a/main.py b/main.py index 32b8b1b..71725da 100644 --- a/main.py +++ b/main.py @@ -115,123 +115,6 @@ def run_tensorboard_script(): subprocess.run(command) -import os -import sys -import wget -import argparse -import subprocess -from rvc.config import Config - -config = Config() -logs_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "logs") - -# Download models -if not os.path.exists("./hubert_base.pt"): - wget.download( - "https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt", - out="./hubert_base.pt", - ) - -if not os.path.exists("./rmvpe.pt"): - wget.download( - "https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/rmvpe.pt", - out="./rmvpe.pt", - ) - -if sys.platform == "win32": - if not os.path.exists("./ffmpeg.exe"): - wget.download( - "https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/ffmpeg.exe", - out="./ffmpeg.exe", - ) -if sys.platform == "win32": - if not os.path.exists("./ffprobe.exe"): - wget.download( - "https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/ffprobe.exe", - out="./ffprobe.exe", - ) - - -# Infer -def validate_f0up_key(value): - try: - f0up_key = int(value) - if -12 <= f0up_key <= 12: - return f0up_key - else: - raise argparse.ArgumentTypeError( - f"f0up_key must be in the range of -12 to +12" - ) - except ValueError: - raise argparse.ArgumentTypeError("f0up_key must be a valid integer") - - -def run_infer_script(f0up_key, f0method, input_path, output_path, pth_file, index_path): - command = [ - "python", - "rvc/infer/infer.py", - str(f0up_key), - f0method, - input_path, - output_path, - pth_file, - index_path, - ] - subprocess.run(command) - - -# Train -def run_preprocess_script(dataset_path, sampling_rate, cpu_processes, model_name): - per = 3.0 if config.is_half else 3.7 - command = [ - "python", - "rvc/train/preprocess.py", - dataset_path, - str(sampling_rate), - str(cpu_processes), - logs_path + "\\" + str(model_name), - "False", - str(per), - ] - - os.mkdir(logs_path + "\\" + str(model_name)) - subprocess.run(command) - - -def run_extract_script( - model_name, rvc_version, cpu_processes, f0method, crepe_hop_length -): - command_1 = [ - "python", - "rvc/train/extract/extract_f0_print.py", - logs_path + "\\" + str(model_name), - cpu_processes, - f0method, - crepe_hop_length, - ] - command_2 = [ - "python", - "rvc/train/extract/extract_feature_print.py", - config.device, - "1", - "0", - "0", - logs_path + "\\" + str(model_name), - rvc_version, - "True", - ] - subprocess.run(command_1) - subprocess.run(command_2) - - -def run_tensorboard_script(): - command = [ - "python", - "rvc/train/launch_tensorboard.py", - ] - subprocess.run(command) - - def parse_arguments(): parser = argparse.ArgumentParser( description="Run the main.py script with specific parameters." @@ -350,42 +233,3 @@ def main(): if __name__ == "__main__": main() - - -def main(): - args = parse_arguments() - - try: - if args.mode == "infer": - run_infer_script( - args.f0up_key, - args.f0method, - args.input_path, - args.output_path, - args.pth_file, - args.index_path, - ) - elif args.mode == "preprocess": - run_preprocess_script( - args.dataset_path, - str(args.sampling_rate), - str(args.cpu_processes), - args.model_name, - ) - - elif args.mode == "extract": - run_extract_script( - args.model_name, - args.rvc_version, - args.cpu_processes, - args.f0method, - args.crepe_hop_length, - ) - elif args.mode == "tensorboard": - run_tensorboard_script() - except Exception as e: - print(f"Error: {e}") - - -if __name__ == "__main__": - main()