Skip to content

Commit a246a66

Browse files
chore(format): run black on dev (#58)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 8ce397d commit a246a66

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

infer/lib/rtrvc.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ def forward_dml(ctx, x, scale):
6161
self.cache_pitch: torch.Tensor = torch.zeros(
6262
1024, device=self.device, dtype=torch.long
6363
)
64-
self.cache_pitchf = torch.zeros(
65-
1024, device=self.device, dtype=torch.float32
66-
)
64+
self.cache_pitchf = torch.zeros(1024, device=self.device, dtype=torch.float32)
6765

6866
self.resample_kernel = {}
6967

@@ -111,13 +109,15 @@ def set_jit_model():
111109
self.tgt_sr = cpt["config"][-1]
112110
self.if_f0 = cpt.get("f0", 1)
113111
self.version = cpt.get("version", "v1")
114-
self.net_g = torch.jit.load(
115-
BytesIO(cpt["model"]), map_location=self.device
116-
)
112+
self.net_g = torch.jit.load(BytesIO(cpt["model"]), map_location=self.device)
117113
self.net_g.infer = self.net_g.forward
118114
self.net_g.eval().to(self.device)
119115

120-
if self.use_jit and not is_dml and not (self.is_half and "cpu" in str(self.device)):
116+
if (
117+
self.use_jit
118+
and not is_dml
119+
and not (self.is_half and "cpu" in str(self.device))
120+
):
121121
set_jit_model()
122122
else:
123123
set_default_model()
@@ -202,9 +202,13 @@ def infer(
202202
elif self.if_f0 == 1:
203203
f0_extractor_frame = block_frame_16k + 800
204204
if f0method == "rmvpe":
205-
f0_extractor_frame = 5120 * ((f0_extractor_frame - 1) // 5120 + 1) - self.window
205+
f0_extractor_frame = (
206+
5120 * ((f0_extractor_frame - 1) // 5120 + 1) - self.window
207+
)
206208
if inp_f0 is not None:
207-
pitch, pitchf = self._get_f0_post(inp_f0, self.f0_up_key - self.formant_shift)
209+
pitch, pitchf = self._get_f0_post(
210+
inp_f0, self.f0_up_key - self.formant_shift
211+
)
208212
else:
209213
pitch, pitchf = self._get_f0(
210214
input_wav[-f0_extractor_frame:],
@@ -272,12 +276,12 @@ def _get_f0(
272276
x: torch.Tensor,
273277
f0_up_key: Union[int, float],
274278
filter_radius: Union[int, float],
275-
method: Literal["crepe", "rmvpe", "fcpe", "pm", "harvest", "dio"]="fcpe",
279+
method: Literal["crepe", "rmvpe", "fcpe", "pm", "harvest", "dio"] = "fcpe",
276280
):
277281
if method not in self.f0_methods.keys():
278-
raise RuntimeError("Not supported f0 method: "+method)
282+
raise RuntimeError("Not supported f0 method: " + method)
279283
return self.f0_methods[method](x, f0_up_key, filter_radius)
280-
284+
281285
def _get_f0_post(self, f0, f0_up_key):
282286
f0 *= pow(2, f0_up_key / 12)
283287
if not torch.is_tensor(f0):
@@ -297,7 +301,7 @@ def _get_f0_pm(self, x, f0_up_key, filter_radius):
297301
self.pm = PM(hop_length=160, sampling_rate=16000)
298302
f0 = self.pm.compute_f0(x)
299303
return self._get_f0_post(f0, f0_up_key)
300-
304+
301305
def _get_f0_harvest(self, x, f0_up_key, filter_radius):
302306
if not hasattr(self, "harvest"):
303307
self.harvest = Harvest(
@@ -308,7 +312,7 @@ def _get_f0_harvest(self, x, f0_up_key, filter_radius):
308312
)
309313
f0 = self.harvest.compute_f0(x, filter_radius=filter_radius)
310314
return self._get_f0_post(f0, f0_up_key)
311-
315+
312316
def _get_f0_dio(self, x, f0_up_key, filter_radius):
313317
if not hasattr(self, "dio"):
314318
self.dio = Dio(
@@ -341,7 +345,8 @@ def _get_f0_rmvpe(self, x, f0_up_key, filter_radius=0.03):
341345
use_jit=self.use_jit,
342346
)
343347
return self._get_f0_post(
344-
self.rmvpe.compute_f0(x, thred=filter_radius), f0_up_key,
348+
self.rmvpe.compute_f0(x, thred=filter_radius),
349+
f0_up_key,
345350
)
346351

347352
def _get_f0_fcpe(self, x, f0_up_key, filter_radius):

0 commit comments

Comments
 (0)