1
0
mirror of https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git synced 2026-06-05 01:10:22 +08:00

chore(format): run black on dev (#98)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2024-11-28 18:07:17 +09:00
committed by GitHub
parent 7befbd10d9
commit 19619161be
5 changed files with 36 additions and 15 deletions

View File

@@ -40,7 +40,7 @@ is_half = sys.argv[5] == "True"
class FeatureInput(object):
def __init__(self, is_half: bool, device = "cpu", samplerate=16000, hop_size=160):
def __init__(self, is_half: bool, device="cpu", samplerate=16000, hop_size=160):
self.fs = samplerate
self.hop = hop_size
@@ -75,7 +75,9 @@ class FeatureInput(object):
):
continue
x = load_audio(inp_path, self.fs)
coarse_pit, feature_pit = self.f0_gen.calculate(x, x.shape[0] // self.hop, 0, f0_method, None)
coarse_pit, feature_pit = self.f0_gen.calculate(
x, x.shape[0] // self.hop, 0, f0_method, None
)
np.save(
opt_path2,
feature_pit,

View File

@@ -73,7 +73,6 @@ class Pipeline(object):
self.sr,
)
def vc(
self,
model,

View File

@@ -15,7 +15,7 @@ def post_process(
manual_x_pad: int,
f0_mel_min: float,
f0_mel_max: float,
manual_f0: Optional[Union[np.ndarray, list]]=None,
manual_f0: Optional[Union[np.ndarray, list]] = None,
) -> Tuple[np.ndarray, np.ndarray]:
f0 = np.multiply(f0, pow(2, f0_up_key / 12))
# with open("test.txt","w")as f:f.write("\n".join([str(i)for i in f0.tolist()]))
@@ -28,10 +28,14 @@ def post_process(
list(range(delta_t)), manual_f0[:, 0] * 100, manual_f0[:, 1]
)
shape = f0[manual_x_pad * tf0 : manual_x_pad * tf0 + len(replace_f0)].shape[0]
f0[manual_x_pad * tf0 : manual_x_pad * tf0 + len(replace_f0)] = replace_f0[:shape]
f0[manual_x_pad * tf0 : manual_x_pad * tf0 + len(replace_f0)] = replace_f0[
:shape
]
# with open("test_opt.txt","w")as f:f.write("\n".join([str(i)for i in f0.tolist()]))
f0_mel = 1127 * np.log(1 + f0 / 700)
f0_mel[f0_mel > 0] = (f0_mel[f0_mel > 0] - f0_mel_min) * 254 / (f0_mel_max - f0_mel_min) + 1
f0_mel[f0_mel > 0] = (f0_mel[f0_mel > 0] - f0_mel_min) * 254 / (
f0_mel_max - f0_mel_min
) + 1
f0_mel[f0_mel <= 1] = 1
f0_mel[f0_mel > 255] = 255
f0_coarse = np.rint(f0_mel).astype(np.int32)
@@ -44,9 +48,9 @@ class Generator(object):
rmvpe_root: Path,
is_half: bool,
x_pad: int,
device = "cpu",
window = 160,
sr = 16000
device="cpu",
window=160,
sr=16000,
):
self.rmvpe_root = rmvpe_root
self.is_half = is_half
@@ -60,30 +64,34 @@ class Generator(object):
x: np.ndarray,
p_len: int,
f0_up_key: int,
f0_method: Literal['pm', 'dio', 'harvest', 'crepe', 'rmvpe', 'fcpe'],
f0_method: Literal["pm", "dio", "harvest", "crepe", "rmvpe", "fcpe"],
filter_radius: Optional[Union[int, float]],
manual_f0: Optional[Union[np.ndarray, list]]=None,
manual_f0: Optional[Union[np.ndarray, list]] = None,
) -> Tuple[np.ndarray, np.ndarray]:
f0_min = 50
f0_max = 1100
if f0_method == "pm":
if not hasattr(self, "pm"):
from .pm import PM
self.pm = PM(self.window, f0_min, f0_max, self.sr)
f0 = self.pm.compute_f0(x, p_len=p_len)
elif f0_method == "dio":
if not hasattr(self, "dio"):
from .dio import Dio
self.dio = Dio(self.window, f0_min, f0_max, self.sr)
f0 = self.dio.compute_f0(x, p_len=p_len)
elif f0_method == "harvest":
if not hasattr(self, "harvest"):
from .harvest import Harvest
self.harvest = Harvest(self.window, f0_min, f0_max, self.sr)
f0 = self.harvest.compute_f0(x, p_len=p_len, filter_radius=filter_radius)
elif f0_method == "crepe":
if not hasattr(self, "crepe"):
from .crepe import CRePE
self.crepe = CRePE(
self.window,
f0_min,
@@ -95,8 +103,9 @@ class Generator(object):
elif f0_method == "rmvpe":
if not hasattr(self, "rmvpe"):
from .rmvpe import RMVPE
self.rmvpe = RMVPE(
str(self.rmvpe_root/"rmvpe.pt"),
str(self.rmvpe_root / "rmvpe.pt"),
is_half=self.is_half,
device=self.device,
# use_jit=self.config.use_jit,
@@ -108,6 +117,7 @@ class Generator(object):
elif f0_method == "fcpe":
if not hasattr(self, "fcpe"):
from .fcpe import FCPE
self.fcpe = FCPE(
self.window,
f0_min,
@@ -120,7 +130,11 @@ class Generator(object):
raise ValueError(f"f0 method {f0_method} has not yet been supported")
return post_process(
self.sr, self.window, f0, f0_up_key, self.x_pad,
self.sr,
self.window,
f0,
f0_up_key,
self.x_pad,
1127 * log(1 + f0_min / 700),
1127 * log(1 + f0_max / 700),
manual_f0,

View File

@@ -76,7 +76,9 @@ class RVC(Model):
hubert = np.repeat(hubert, 2, axis=2).transpose(0, 2, 1).astype(np.float32)
hubert_length = hubert.shape[1]
pitch, pitchf = self.f0_gen.calculate(wav, hubert_length, f0_up_key, f0_method, None)
pitch, pitchf = self.f0_gen.calculate(
wav, hubert_length, f0_up_key, f0_method, None
)
pitch = pitch.astype(np.int64)
pitchf = pitchf.reshape(1, len(pitchf)).astype(np.float32)

6
web.py
View File

@@ -691,7 +691,11 @@ def train1key(
[
get_info_str(_)
for _ in extract_f0_feature(
np7, f0method8, if_f0_3, exp_dir1, version19,
np7,
f0method8,
if_f0_3,
exp_dir1,
version19,
)
]