(self)
| 400 | self.event_handler() |
| 401 | |
| 402 | def event_handler(self): |
| 403 | while True: |
| 404 | event, values = self.window.read() |
| 405 | if event == sg.WINDOW_CLOSED: |
| 406 | self.flag_vc = False |
| 407 | exit() |
| 408 | if event == "reload_devices": |
| 409 | prev_input = self.window["sg_input_device"].get() |
| 410 | prev_output = self.window["sg_output_device"].get() |
| 411 | input_devices, output_devices, _, _ = self.get_devices(update=True) |
| 412 | if prev_input not in input_devices: |
| 413 | self.gui_config.sg_input_device = input_devices[0] |
| 414 | else: |
| 415 | self.gui_config.sg_input_device = prev_input |
| 416 | self.window["sg_input_device"].Update(values=input_devices) |
| 417 | self.window["sg_input_device"].Update( |
| 418 | value=self.gui_config.sg_input_device |
| 419 | ) |
| 420 | if prev_output not in output_devices: |
| 421 | self.gui_config.sg_output_device = output_devices[0] |
| 422 | else: |
| 423 | self.gui_config.sg_output_device = prev_output |
| 424 | self.window["sg_output_device"].Update(values=output_devices) |
| 425 | self.window["sg_output_device"].Update( |
| 426 | value=self.gui_config.sg_output_device |
| 427 | ) |
| 428 | if event == "start_vc" and self.flag_vc == False: |
| 429 | if self.set_values(values) == True: |
| 430 | printt("cuda_is_available: %s", torch.cuda.is_available()) |
| 431 | self.start_vc() |
| 432 | settings = { |
| 433 | "pth_path": values["pth_path"], |
| 434 | "index_path": values["index_path"], |
| 435 | "sg_input_device": values["sg_input_device"], |
| 436 | "sg_output_device": values["sg_output_device"], |
| 437 | "threhold": values["threhold"], |
| 438 | "pitch": values["pitch"], |
| 439 | "rms_mix_rate": values["rms_mix_rate"], |
| 440 | "index_rate": values["index_rate"], |
| 441 | # "device_latency": values["device_latency"], |
| 442 | "block_time": values["block_time"], |
| 443 | "crossfade_length": values["crossfade_length"], |
| 444 | "extra_time": values["extra_time"], |
| 445 | "n_cpu": values["n_cpu"], |
| 446 | # "use_jit": values["use_jit"], |
| 447 | "use_jit": False, |
| 448 | "f0method": ["pm", "harvest", "crepe", "rmvpe"][ |
| 449 | [ |
| 450 | values["pm"], |
| 451 | values["harvest"], |
| 452 | values["crepe"], |
| 453 | values["rmvpe"], |
| 454 | ].index(True) |
| 455 | ], |
| 456 | } |
| 457 | with open("configs/config.json", "w") as j: |
| 458 | json.dump(settings, j) |
| 459 | global stream_latency |
no test coverage detected