Format code (#1296)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
github-actions[bot] 2023-09-21 23:18:12 +09:00 committed by GitHub
parent ac1397f3f9
commit 4a804fbcbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,7 @@ import multiprocessing
logger = logging.getLogger(__name__)
stream_latency = -1
class Harvest(multiprocessing.Process):
def __init__(self, inp_q, opt_q):
multiprocessing.Process.__init__(self)
@ -100,7 +101,7 @@ if __name__ == "__main__":
def __init__(self) -> None:
self.config = GUIConfig()
self.flag_vc = False
self.function = 'vc'
self.function = "vc"
self.delay_time = 0
self.launcher()
@ -116,7 +117,7 @@ if __name__ == "__main__":
if data["sg_input_device"] not in input_devices:
data["sg_input_device"] = input_devices[sd.default.device[0]]
if data["sg_output_device"] not in output_devices:
data["sg_output_device"] = output_devices[sd.default.device[1]]
data["sg_output_device"] = output_devices[sd.default.device[1]]
except:
with open("configs/config.json", "w") as j:
data = {
@ -353,7 +354,7 @@ if __name__ == "__main__":
key="im",
default=False,
enable_events=True,
),
),
sg.Radio(
i18n("输出变声"),
"function",
@ -427,7 +428,12 @@ if __name__ == "__main__":
global stream_latency
while stream_latency < 0:
time.sleep(0.01)
self.delay_time = stream_latency + values["block_time"] + values["crossfade_length"] + 0.01
self.delay_time = (
stream_latency
+ values["block_time"]
+ values["crossfade_length"]
+ 0.01
)
if values["I_noise_reduce"]:
self.delay_time += values["crossfade_length"]
self.window["delay_time"].update(int(self.delay_time * 1000))
@ -452,7 +458,9 @@ if __name__ == "__main__":
elif event == "I_noise_reduce":
self.config.I_noise_reduce = values["I_noise_reduce"]
if stream_latency > 0:
self.delay_time += (1 if values["I_noise_reduce"] else -1) * values["crossfade_length"]
self.delay_time += (
1 if values["I_noise_reduce"] else -1
) * values["crossfade_length"]
self.window["delay_time"].update(int(self.delay_time * 1000))
elif event == "O_noise_reduce":
self.config.O_noise_reduce = values["O_noise_reduce"]
@ -633,7 +641,7 @@ if __name__ == "__main__":
self.block_frame_16k :
].clone()
# input noise reduction and resampling
if self.config.I_noise_reduce and self.function == 'vc':
if self.config.I_noise_reduce and self.function == "vc":
input_wav = self.input_wav[
-self.crossfade_frame - self.block_frame - 2 * self.zc :
]
@ -657,10 +665,12 @@ if __name__ == "__main__":
self.input_wav[-self.block_frame - 2 * self.zc :]
)[160:]
# infer
if self.function == 'vc':
if self.function == "vc":
f0_extractor_frame = self.block_frame_16k + 800
if self.config.f0method == "rmvpe":
f0_extractor_frame = 5120 * ((f0_extractor_frame - 1) // 5120 + 1) - 160
f0_extractor_frame = (
5120 * ((f0_extractor_frame - 1) // 5120 + 1) - 160
)
infer_wav = self.rvc.infer(
self.input_wav_res,
self.input_wav_res[-f0_extractor_frame:].cpu().numpy(),
@ -678,7 +688,9 @@ if __name__ == "__main__":
-self.crossfade_frame - self.sola_search_frame - self.block_frame :
].clone()
# output noise reduction
if (self.config.O_noise_reduce and self.function == 'vc') or (self.config.I_noise_reduce and self.function == 'im'):
if (self.config.O_noise_reduce and self.function == "vc") or (
self.config.I_noise_reduce and self.function == "im"
):
self.output_buffer[: -self.block_frame] = self.output_buffer[
self.block_frame :
].clone()
@ -687,7 +699,7 @@ if __name__ == "__main__":
infer_wav.unsqueeze(0), self.output_buffer.unsqueeze(0)
).squeeze(0)
# volume envelop mixing
if self.config.rms_mix_rate < 1 and self.function == 'vc':
if self.config.rms_mix_rate < 1 and self.function == "vc":
rms1 = librosa.feature.rms(
y=self.input_wav_res[-160 * infer_wav.shape[0] // self.zc :]
.cpu()