Skip to content

Commit

Permalink
change per value to a fixed one
Browse files Browse the repository at this point in the history
  • Loading branch information
blaisewf committed Dec 27, 2024
1 parent 4770fc8 commit a85d729
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
3 changes: 0 additions & 3 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,6 @@ def run_preprocess_script(
chunk_len: float,
overlap_len: float,
):
config = get_config()
per = 3.0 if config.is_half else 3.7
preprocess_script_path = os.path.join("rvc", "train", "preprocess", "preprocess.py")
command = [
python,
Expand All @@ -439,7 +437,6 @@ def run_preprocess_script(
os.path.join(logs_path, model_name),
dataset_path,
sample_rate,
per,
cpu_cores,
cut_preprocess,
process_effects,
Expand Down
29 changes: 13 additions & 16 deletions rvc/train/preprocess/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
logging.getLogger("numba.core.interpreter").setLevel(logging.WARNING)

OVERLAP = 0.3
PERCENTAGE = 3.0
MAX_AMPLITUDE = 0.9
ALPHA = 0.75
HIGH_PASS_CUTOFF = 48
Expand All @@ -34,7 +35,7 @@


class PreProcess:
def __init__(self, sr: int, exp_dir: str, per: float):
def __init__(self, sr: int, exp_dir: str):
self.slicer = Slicer(
sr=sr,
threshold=-42,
Expand All @@ -47,7 +48,6 @@ def __init__(self, sr: int, exp_dir: str, per: float):
self.b_high, self.a_high = signal.butter(
N=5, Wn=HIGH_PASS_CUTOFF, btype="high", fs=self.sr
)
self.per = per
self.exp_dir = exp_dir
self.device = "cpu"
self.gt_wavs_dir = os.path.join(exp_dir, "sliced_audios")
Expand Down Expand Up @@ -166,11 +166,11 @@ def process_audio(
for audio_segment in self.slicer.slice(audio):
i = 0
while True:
start = int(self.sr * (self.per - OVERLAP) * i)
start = int(self.sr * (PERCENTAGE - OVERLAP) * i)
i += 1
if len(audio_segment[start:]) > (self.per + OVERLAP) * self.sr:
if len(audio_segment[start:]) > (PERCENTAGE + OVERLAP) * self.sr:
tmp_audio = audio_segment[
start : start + int(self.per * self.sr)
start : start + int(PERCENTAGE * self.sr)
]
self.process_audio_segment(
tmp_audio,
Expand Down Expand Up @@ -250,7 +250,6 @@ def preprocess_training_set(
sr: int,
num_processes: int,
exp_dir: str,
per: float,
cut_preprocess: str,
process_effects: bool,
noise_reduction: bool,
Expand All @@ -259,7 +258,7 @@ def preprocess_training_set(
overlap_len: float,
):
start_time = time.time()
pp = PreProcess(sr, exp_dir, per)
pp = PreProcess(sr, exp_dir)
print(f"Starting preprocess with {num_processes} processes...")

files = []
Expand Down Expand Up @@ -317,25 +316,23 @@ def preprocess_training_set(
experiment_directory = str(sys.argv[1])
input_root = str(sys.argv[2])
sample_rate = int(sys.argv[3])
percentage = float(sys.argv[4])
num_processes = sys.argv[5]
num_processes = sys.argv[4]
if num_processes.lower() == "none":
num_processes = multiprocessing.cpu_count()
else:
num_processes = int(num_processes)
cut_preprocess = str(sys.argv[6])
process_effects = strtobool(sys.argv[7])
noise_reduction = strtobool(sys.argv[8])
reduction_strength = float(sys.argv[9])
chunk_len = float(sys.argv[10])
overlap_len = float(sys.argv[11])
cut_preprocess = str(sys.argv[5])
process_effects = strtobool(sys.argv[6])
noise_reduction = strtobool(sys.argv[7])
reduction_strength = float(sys.argv[8])
chunk_len = float(sys.argv[9])
overlap_len = float(sys.argv[10])

preprocess_training_set(
input_root,
sample_rate,
num_processes,
experiment_directory,
percentage,
cut_preprocess,
process_effects,
noise_reduction,
Expand Down

0 comments on commit a85d729

Please sign in to comment.