Skip to content

Commit 1961916

Browse files
chore(format): run black on dev (#98)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 7befbd1 commit 1961916

File tree

5 files changed

+36
-15
lines changed

5 files changed

+36
-15
lines changed

infer/modules/train/extract_f0_print.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def printt(strr):
4040

4141

4242
class FeatureInput(object):
43-
def __init__(self, is_half: bool, device = "cpu", samplerate=16000, hop_size=160):
43+
def __init__(self, is_half: bool, device="cpu", samplerate=16000, hop_size=160):
4444
self.fs = samplerate
4545
self.hop = hop_size
4646

@@ -75,7 +75,9 @@ def go(self, paths, f0_method):
7575
):
7676
continue
7777
x = load_audio(inp_path, self.fs)
78-
coarse_pit, feature_pit = self.f0_gen.calculate(x, x.shape[0] // self.hop, 0, f0_method, None)
78+
coarse_pit, feature_pit = self.f0_gen.calculate(
79+
x, x.shape[0] // self.hop, 0, f0_method, None
80+
)
7981
np.save(
8082
opt_path2,
8183
feature_pit,

infer/modules/vc/pipeline.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ def __init__(self, tgt_sr, config):
7373
self.sr,
7474
)
7575

76-
7776
def vc(
7877
self,
7978
model,

rvc/f0/gen.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def post_process(
1515
manual_x_pad: int,
1616
f0_mel_min: float,
1717
f0_mel_max: float,
18-
manual_f0: Optional[Union[np.ndarray, list]]=None,
18+
manual_f0: Optional[Union[np.ndarray, list]] = None,
1919
) -> Tuple[np.ndarray, np.ndarray]:
2020
f0 = np.multiply(f0, pow(2, f0_up_key / 12))
2121
# 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(
2828
list(range(delta_t)), manual_f0[:, 0] * 100, manual_f0[:, 1]
2929
)
3030
shape = f0[manual_x_pad * tf0 : manual_x_pad * tf0 + len(replace_f0)].shape[0]
31-
f0[manual_x_pad * tf0 : manual_x_pad * tf0 + len(replace_f0)] = replace_f0[:shape]
31+
f0[manual_x_pad * tf0 : manual_x_pad * tf0 + len(replace_f0)] = replace_f0[
32+
:shape
33+
]
3234
# with open("test_opt.txt","w")as f:f.write("\n".join([str(i)for i in f0.tolist()]))
3335
f0_mel = 1127 * np.log(1 + f0 / 700)
34-
f0_mel[f0_mel > 0] = (f0_mel[f0_mel > 0] - f0_mel_min) * 254 / (f0_mel_max - f0_mel_min) + 1
36+
f0_mel[f0_mel > 0] = (f0_mel[f0_mel > 0] - f0_mel_min) * 254 / (
37+
f0_mel_max - f0_mel_min
38+
) + 1
3539
f0_mel[f0_mel <= 1] = 1
3640
f0_mel[f0_mel > 255] = 255
3741
f0_coarse = np.rint(f0_mel).astype(np.int32)
@@ -44,9 +48,9 @@ def __init__(
4448
rmvpe_root: Path,
4549
is_half: bool,
4650
x_pad: int,
47-
device = "cpu",
48-
window = 160,
49-
sr = 16000
51+
device="cpu",
52+
window=160,
53+
sr=16000,
5054
):
5155
self.rmvpe_root = rmvpe_root
5256
self.is_half = is_half
@@ -60,30 +64,34 @@ def calculate(
6064
x: np.ndarray,
6165
p_len: int,
6266
f0_up_key: int,
63-
f0_method: Literal['pm', 'dio', 'harvest', 'crepe', 'rmvpe', 'fcpe'],
67+
f0_method: Literal["pm", "dio", "harvest", "crepe", "rmvpe", "fcpe"],
6468
filter_radius: Optional[Union[int, float]],
65-
manual_f0: Optional[Union[np.ndarray, list]]=None,
69+
manual_f0: Optional[Union[np.ndarray, list]] = None,
6670
) -> Tuple[np.ndarray, np.ndarray]:
6771
f0_min = 50
6872
f0_max = 1100
6973
if f0_method == "pm":
7074
if not hasattr(self, "pm"):
7175
from .pm import PM
76+
7277
self.pm = PM(self.window, f0_min, f0_max, self.sr)
7378
f0 = self.pm.compute_f0(x, p_len=p_len)
7479
elif f0_method == "dio":
7580
if not hasattr(self, "dio"):
7681
from .dio import Dio
82+
7783
self.dio = Dio(self.window, f0_min, f0_max, self.sr)
7884
f0 = self.dio.compute_f0(x, p_len=p_len)
7985
elif f0_method == "harvest":
8086
if not hasattr(self, "harvest"):
8187
from .harvest import Harvest
88+
8289
self.harvest = Harvest(self.window, f0_min, f0_max, self.sr)
8390
f0 = self.harvest.compute_f0(x, p_len=p_len, filter_radius=filter_radius)
8491
elif f0_method == "crepe":
8592
if not hasattr(self, "crepe"):
8693
from .crepe import CRePE
94+
8795
self.crepe = CRePE(
8896
self.window,
8997
f0_min,
@@ -95,8 +103,9 @@ def calculate(
95103
elif f0_method == "rmvpe":
96104
if not hasattr(self, "rmvpe"):
97105
from .rmvpe import RMVPE
106+
98107
self.rmvpe = RMVPE(
99-
str(self.rmvpe_root/"rmvpe.pt"),
108+
str(self.rmvpe_root / "rmvpe.pt"),
100109
is_half=self.is_half,
101110
device=self.device,
102111
# use_jit=self.config.use_jit,
@@ -108,6 +117,7 @@ def calculate(
108117
elif f0_method == "fcpe":
109118
if not hasattr(self, "fcpe"):
110119
from .fcpe import FCPE
120+
111121
self.fcpe = FCPE(
112122
self.window,
113123
f0_min,
@@ -120,7 +130,11 @@ def calculate(
120130
raise ValueError(f"f0 method {f0_method} has not yet been supported")
121131

122132
return post_process(
123-
self.sr, self.window, f0, f0_up_key, self.x_pad,
133+
self.sr,
134+
self.window,
135+
f0,
136+
f0_up_key,
137+
self.x_pad,
124138
1127 * log(1 + f0_min / 700),
125139
1127 * log(1 + f0_max / 700),
126140
manual_f0,

rvc/onnx/infer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def infer(
7676
hubert = np.repeat(hubert, 2, axis=2).transpose(0, 2, 1).astype(np.float32)
7777
hubert_length = hubert.shape[1]
7878

79-
pitch, pitchf = self.f0_gen.calculate(wav, hubert_length, f0_up_key, f0_method, None)
79+
pitch, pitchf = self.f0_gen.calculate(
80+
wav, hubert_length, f0_up_key, f0_method, None
81+
)
8082
pitch = pitch.astype(np.int64)
8183

8284
pitchf = pitchf.reshape(1, len(pitchf)).astype(np.float32)

web.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,11 @@ def get_info_str(strr):
691691
[
692692
get_info_str(_)
693693
for _ in extract_f0_feature(
694-
np7, f0method8, if_f0_3, exp_dir1, version19,
694+
np7,
695+
f0method8,
696+
if_f0_3,
697+
exp_dir1,
698+
version19,
695699
)
696700
]
697701

0 commit comments

Comments
 (0)