Skip to content

Commit 4a804fb

Browse files
Format code (#1296)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent ac1397f commit 4a804fb

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

gui_v1.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
logger = logging.getLogger(__name__)
1717
stream_latency = -1
1818

19+
1920
class Harvest(multiprocessing.Process):
2021
def __init__(self, inp_q, opt_q):
2122
multiprocessing.Process.__init__(self)
@@ -100,7 +101,7 @@ class GUI:
100101
def __init__(self) -> None:
101102
self.config = GUIConfig()
102103
self.flag_vc = False
103-
self.function = 'vc'
104+
self.function = "vc"
104105
self.delay_time = 0
105106
self.launcher()
106107

@@ -116,7 +117,7 @@ def load(self):
116117
if data["sg_input_device"] not in input_devices:
117118
data["sg_input_device"] = input_devices[sd.default.device[0]]
118119
if data["sg_output_device"] not in output_devices:
119-
data["sg_output_device"] = output_devices[sd.default.device[1]]
120+
data["sg_output_device"] = output_devices[sd.default.device[1]]
120121
except:
121122
with open("configs/config.json", "w") as j:
122123
data = {
@@ -353,7 +354,7 @@ def launcher(self):
353354
key="im",
354355
default=False,
355356
enable_events=True,
356-
),
357+
),
357358
sg.Radio(
358359
i18n("输出变声"),
359360
"function",
@@ -427,7 +428,12 @@ def event_handler(self):
427428
global stream_latency
428429
while stream_latency < 0:
429430
time.sleep(0.01)
430-
self.delay_time = stream_latency + values["block_time"] + values["crossfade_length"] + 0.01
431+
self.delay_time = (
432+
stream_latency
433+
+ values["block_time"]
434+
+ values["crossfade_length"]
435+
+ 0.01
436+
)
431437
if values["I_noise_reduce"]:
432438
self.delay_time += values["crossfade_length"]
433439
self.window["delay_time"].update(int(self.delay_time * 1000))
@@ -452,7 +458,9 @@ def event_handler(self):
452458
elif event == "I_noise_reduce":
453459
self.config.I_noise_reduce = values["I_noise_reduce"]
454460
if stream_latency > 0:
455-
self.delay_time += (1 if values["I_noise_reduce"] else -1) * values["crossfade_length"]
461+
self.delay_time += (
462+
1 if values["I_noise_reduce"] else -1
463+
) * values["crossfade_length"]
456464
self.window["delay_time"].update(int(self.delay_time * 1000))
457465
elif event == "O_noise_reduce":
458466
self.config.O_noise_reduce = values["O_noise_reduce"]
@@ -633,7 +641,7 @@ def audio_callback(
633641
self.block_frame_16k :
634642
].clone()
635643
# input noise reduction and resampling
636-
if self.config.I_noise_reduce and self.function == 'vc':
644+
if self.config.I_noise_reduce and self.function == "vc":
637645
input_wav = self.input_wav[
638646
-self.crossfade_frame - self.block_frame - 2 * self.zc :
639647
]
@@ -657,10 +665,12 @@ def audio_callback(
657665
self.input_wav[-self.block_frame - 2 * self.zc :]
658666
)[160:]
659667
# infer
660-
if self.function == 'vc':
668+
if self.function == "vc":
661669
f0_extractor_frame = self.block_frame_16k + 800
662670
if self.config.f0method == "rmvpe":
663-
f0_extractor_frame = 5120 * ((f0_extractor_frame - 1) // 5120 + 1) - 160
671+
f0_extractor_frame = (
672+
5120 * ((f0_extractor_frame - 1) // 5120 + 1) - 160
673+
)
664674
infer_wav = self.rvc.infer(
665675
self.input_wav_res,
666676
self.input_wav_res[-f0_extractor_frame:].cpu().numpy(),
@@ -678,7 +688,9 @@ def audio_callback(
678688
-self.crossfade_frame - self.sola_search_frame - self.block_frame :
679689
].clone()
680690
# output noise reduction
681-
if (self.config.O_noise_reduce and self.function == 'vc') or (self.config.I_noise_reduce and self.function == 'im'):
691+
if (self.config.O_noise_reduce and self.function == "vc") or (
692+
self.config.I_noise_reduce and self.function == "im"
693+
):
682694
self.output_buffer[: -self.block_frame] = self.output_buffer[
683695
self.block_frame :
684696
].clone()
@@ -687,7 +699,7 @@ def audio_callback(
687699
infer_wav.unsqueeze(0), self.output_buffer.unsqueeze(0)
688700
).squeeze(0)
689701
# volume envelop mixing
690-
if self.config.rms_mix_rate < 1 and self.function == 'vc':
702+
if self.config.rms_mix_rate < 1 and self.function == "vc":
691703
rms1 = librosa.feature.rms(
692704
y=self.input_wav_res[-160 * infer_wav.shape[0] // self.zc :]
693705
.cpu()

0 commit comments

Comments
 (0)