Skip to content

Commit

Permalink
duplicated code (idk why)
Browse files Browse the repository at this point in the history
  • Loading branch information
blaisewf committed Dec 12, 2023
1 parent 710665d commit fe0584b
Showing 1 changed file with 0 additions and 156 deletions.
156 changes: 0 additions & 156 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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()

0 comments on commit fe0584b

Please sign in to comment.