diff --git a/app.py b/app.py index 4c5b0949f..82958dbf0 100644 --- a/app.py +++ b/app.py @@ -3,7 +3,6 @@ import os import logging -# Constants DEFAULT_PORT = 6969 MAX_PORT_ATTEMPTS = 10 diff --git a/rvc/configs/config.py b/rvc/configs/config.py index ed5447e1d..71f12bc22 100644 --- a/rvc/configs/config.py +++ b/rvc/configs/config.py @@ -37,7 +37,7 @@ def __init__(self): self.gpu_mem = None self.x_pad, self.x_query, self.x_center, self.x_max = self.device_config() - def load_config_json(self) -> dict: + def load_config_json(self): configs = {} for config_file in version_config_paths: config_path = os.path.join("rvc", "configs", config_file) @@ -97,7 +97,7 @@ def get_precision(self): print(f"File not found: {full_config_path}") return None - def device_config(self) -> tuple: + def device_config(self): if self.device.startswith("cuda"): self.set_cuda_config() else: diff --git a/rvc/infer/pipeline.py b/rvc/infer/pipeline.py index 6f9e554e4..bf82afd4c 100644 --- a/rvc/infer/pipeline.py +++ b/rvc/infer/pipeline.py @@ -21,7 +21,6 @@ logging.getLogger("faiss").setLevel(logging.WARNING) -# Constants for high-pass filter FILTER_ORDER = 5 CUTOFF_FREQUENCY = 48 # Hz SAMPLE_RATE = 16000 # Hz @@ -43,7 +42,7 @@ def change_rms( target_audio: np.ndarray, target_rate: int, rate: float, - ) -> np.ndarray: + ): """ Adjust the RMS level of target_audio to match the RMS of source_audio, with a given blending rate. diff --git a/rvc/lib/algorithm/commons.py b/rvc/lib/algorithm/commons.py index 2524abc41..eed8d7c37 100644 --- a/rvc/lib/algorithm/commons.py +++ b/rvc/lib/algorithm/commons.py @@ -157,7 +157,7 @@ def fused_add_tanh_sigmoid_multiply(input_a, input_b, n_channels): return acts -def convert_pad_shape(pad_shape: List[List[int]]) -> List[int]: +def convert_pad_shape(pad_shape: List[List[int]]): """ Convert the pad shape to a list of integers. diff --git a/rvc/lib/algorithm/generators.py b/rvc/lib/algorithm/generators.py index e0c0ebbcd..c380eabfc 100644 --- a/rvc/lib/algorithm/generators.py +++ b/rvc/lib/algorithm/generators.py @@ -135,7 +135,7 @@ def __init__( self.voiced_threshold = voiced_threshold self.waveform_dim = self.num_harmonics + 1 # fundamental + harmonics - def _compute_voiced_unvoiced(self, f0: torch.Tensor) -> torch.Tensor: + def _compute_voiced_unvoiced(self, f0: torch.Tensor): """ Generate a binary mask to indicate voiced/unvoiced frames. @@ -145,9 +145,7 @@ def _compute_voiced_unvoiced(self, f0: torch.Tensor) -> torch.Tensor: uv_mask = (f0 > self.voiced_threshold).float() return uv_mask - def _generate_sine_wave( - self, f0: torch.Tensor, upsampling_factor: int - ) -> torch.Tensor: + def _generate_sine_wave(self, f0: torch.Tensor, upsampling_factor: int): """ Generate sine waves for the fundamental frequency and its harmonics. diff --git a/rvc/lib/predictors/F0Extractor.py b/rvc/lib/predictors/F0Extractor.py index bc3b61f3d..b5dbd602c 100644 --- a/rvc/lib/predictors/F0Extractor.py +++ b/rvc/lib/predictors/F0Extractor.py @@ -30,14 +30,14 @@ def __post_init__(self): self.x, self.sample_rate = librosa.load(self.wav_path, sr=self.sample_rate) @property - def hop_size(self) -> float: + def hop_size(self): return self.hop_length / self.sample_rate @property - def wav16k(self) -> np.ndarray: + def wav16k(self): return resampy.resample(self.x, self.sample_rate, 16000) - def extract_f0(self) -> np.ndarray: + def extract_f0(self): f0 = None method = self.method if method == "crepe": diff --git a/rvc/lib/predictors/RMVPE.py b/rvc/lib/predictors/RMVPE.py index 970c5e58f..065b357ff 100644 --- a/rvc/lib/predictors/RMVPE.py +++ b/rvc/lib/predictors/RMVPE.py @@ -6,12 +6,10 @@ from librosa.filters import mel from typing import List -# Constants for readability N_MELS = 128 N_CLASS = 360 -# Define a helper function for creating convolutional blocks class ConvBlockRes(nn.Module): """ A convolutional block with residual connection. @@ -59,7 +57,6 @@ def forward(self, x): return self.conv(x) + x -# Define a class for residual encoder blocks class ResEncoderBlock(nn.Module): """ A residual encoder block. @@ -94,7 +91,6 @@ def forward(self, x): return x -# Define a class for the encoder class Encoder(nn.Module): """ The encoder part of the DeepUnet. @@ -146,7 +142,6 @@ def forward(self, x: torch.Tensor): return x, concat_tensors -# Define a class for the intermediate layer class Intermediate(nn.Module): """ The intermediate layer of the DeepUnet. @@ -177,7 +172,6 @@ def forward(self, x): return x -# Define a class for residual decoder blocks class ResDecoderBlock(nn.Module): """ A residual decoder block. @@ -220,7 +214,6 @@ def forward(self, x, concat_tensor): return x -# Define a class for the decoder class Decoder(nn.Module): """ The decoder part of the DeepUnet. @@ -250,7 +243,6 @@ def forward(self, x, concat_tensors): return x -# Define a class for the DeepUnet architecture class DeepUnet(nn.Module): """ The DeepUnet architecture. @@ -294,7 +286,6 @@ def forward(self, x): return x -# Define a class for the end-to-end model class E2E(nn.Module): """ The end-to-end model. @@ -348,7 +339,6 @@ def forward(self, mel): return x -# Define a class for the MelSpectrogram extractor class MelSpectrogram(torch.nn.Module): """ Extracts Mel-spectrogram features from audio. @@ -432,7 +422,6 @@ def forward(self, audio, keyshift=0, speed=1, center=True): return log_mel_spec -# Define a class for the RMVPE0 predictor class RMVPE0Predictor: """ A predictor for fundamental frequency (F0) based on the RMVPE0 model. @@ -535,7 +524,6 @@ def to_local_average_cents(self, salience, thred=0.05): return devided -# Define a class for BiGRU (bidirectional GRU) class BiGRU(nn.Module): """ A bidirectional GRU layer. diff --git a/rvc/train/preprocess/preprocess.py b/rvc/train/preprocess/preprocess.py index ef80a28c3..c9c865491 100644 --- a/rvc/train/preprocess/preprocess.py +++ b/rvc/train/preprocess/preprocess.py @@ -25,7 +25,6 @@ logging.getLogger("numba.core.ssa").setLevel(logging.WARNING) logging.getLogger("numba.core.interpreter").setLevel(logging.WARNING) -# Constants OVERLAP = 0.3 MAX_AMPLITUDE = 0.9 ALPHA = 0.75 diff --git a/tabs/extra/f0_extractor/f0_extractor.py b/tabs/extra/f0_extractor/f0_extractor.py index a6a05e30d..96af31042 100644 --- a/tabs/extra/f0_extractor/f0_extractor.py +++ b/tabs/extra/f0_extractor/f0_extractor.py @@ -10,7 +10,7 @@ i18n = I18nAuto() -def extract_f0_curve(audio_path: str, method: str) -> tuple: +def extract_f0_curve(audio_path: str, method: str): print("Extracting F0 Curve...") image_path = os.path.join("logs", "f0_plot.png") txt_path = os.path.join("logs", "f0_curve.txt")