mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2025-01-19 21:00:11 +08:00
Format code (#1296)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
ac1397f3f9
commit
4a804fbcbb
32
gui_v1.py
32
gui_v1.py
@ -16,6 +16,7 @@ import multiprocessing
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
stream_latency = -1
|
stream_latency = -1
|
||||||
|
|
||||||
|
|
||||||
class Harvest(multiprocessing.Process):
|
class Harvest(multiprocessing.Process):
|
||||||
def __init__(self, inp_q, opt_q):
|
def __init__(self, inp_q, opt_q):
|
||||||
multiprocessing.Process.__init__(self)
|
multiprocessing.Process.__init__(self)
|
||||||
@ -100,7 +101,7 @@ if __name__ == "__main__":
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.config = GUIConfig()
|
self.config = GUIConfig()
|
||||||
self.flag_vc = False
|
self.flag_vc = False
|
||||||
self.function = 'vc'
|
self.function = "vc"
|
||||||
self.delay_time = 0
|
self.delay_time = 0
|
||||||
self.launcher()
|
self.launcher()
|
||||||
|
|
||||||
@ -116,7 +117,7 @@ if __name__ == "__main__":
|
|||||||
if data["sg_input_device"] not in input_devices:
|
if data["sg_input_device"] not in input_devices:
|
||||||
data["sg_input_device"] = input_devices[sd.default.device[0]]
|
data["sg_input_device"] = input_devices[sd.default.device[0]]
|
||||||
if data["sg_output_device"] not in output_devices:
|
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:
|
except:
|
||||||
with open("configs/config.json", "w") as j:
|
with open("configs/config.json", "w") as j:
|
||||||
data = {
|
data = {
|
||||||
@ -353,7 +354,7 @@ if __name__ == "__main__":
|
|||||||
key="im",
|
key="im",
|
||||||
default=False,
|
default=False,
|
||||||
enable_events=True,
|
enable_events=True,
|
||||||
),
|
),
|
||||||
sg.Radio(
|
sg.Radio(
|
||||||
i18n("输出变声"),
|
i18n("输出变声"),
|
||||||
"function",
|
"function",
|
||||||
@ -427,7 +428,12 @@ if __name__ == "__main__":
|
|||||||
global stream_latency
|
global stream_latency
|
||||||
while stream_latency < 0:
|
while stream_latency < 0:
|
||||||
time.sleep(0.01)
|
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"]:
|
if values["I_noise_reduce"]:
|
||||||
self.delay_time += values["crossfade_length"]
|
self.delay_time += values["crossfade_length"]
|
||||||
self.window["delay_time"].update(int(self.delay_time * 1000))
|
self.window["delay_time"].update(int(self.delay_time * 1000))
|
||||||
@ -452,7 +458,9 @@ if __name__ == "__main__":
|
|||||||
elif event == "I_noise_reduce":
|
elif event == "I_noise_reduce":
|
||||||
self.config.I_noise_reduce = values["I_noise_reduce"]
|
self.config.I_noise_reduce = values["I_noise_reduce"]
|
||||||
if stream_latency > 0:
|
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))
|
self.window["delay_time"].update(int(self.delay_time * 1000))
|
||||||
elif event == "O_noise_reduce":
|
elif event == "O_noise_reduce":
|
||||||
self.config.O_noise_reduce = values["O_noise_reduce"]
|
self.config.O_noise_reduce = values["O_noise_reduce"]
|
||||||
@ -633,7 +641,7 @@ if __name__ == "__main__":
|
|||||||
self.block_frame_16k :
|
self.block_frame_16k :
|
||||||
].clone()
|
].clone()
|
||||||
# input noise reduction and resampling
|
# 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[
|
input_wav = self.input_wav[
|
||||||
-self.crossfade_frame - self.block_frame - 2 * self.zc :
|
-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 :]
|
self.input_wav[-self.block_frame - 2 * self.zc :]
|
||||||
)[160:]
|
)[160:]
|
||||||
# infer
|
# infer
|
||||||
if self.function == 'vc':
|
if self.function == "vc":
|
||||||
f0_extractor_frame = self.block_frame_16k + 800
|
f0_extractor_frame = self.block_frame_16k + 800
|
||||||
if self.config.f0method == "rmvpe":
|
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(
|
infer_wav = self.rvc.infer(
|
||||||
self.input_wav_res,
|
self.input_wav_res,
|
||||||
self.input_wav_res[-f0_extractor_frame:].cpu().numpy(),
|
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 :
|
-self.crossfade_frame - self.sola_search_frame - self.block_frame :
|
||||||
].clone()
|
].clone()
|
||||||
# output noise reduction
|
# 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.output_buffer[: -self.block_frame] = self.output_buffer[
|
||||||
self.block_frame :
|
self.block_frame :
|
||||||
].clone()
|
].clone()
|
||||||
@ -687,7 +699,7 @@ if __name__ == "__main__":
|
|||||||
infer_wav.unsqueeze(0), self.output_buffer.unsqueeze(0)
|
infer_wav.unsqueeze(0), self.output_buffer.unsqueeze(0)
|
||||||
).squeeze(0)
|
).squeeze(0)
|
||||||
# volume envelop mixing
|
# 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(
|
rms1 = librosa.feature.rms(
|
||||||
y=self.input_wav_res[-160 * infer_wav.shape[0] // self.zc :]
|
y=self.input_wav_res[-160 * infer_wav.shape[0] // self.zc :]
|
||||||
.cpu()
|
.cpu()
|
||||||
|
Loading…
Reference in New Issue
Block a user