From bd2736af5bb95d3d602ea08454bb36e1e2369945 Mon Sep 17 00:00:00 2001 From: 34j <55338215+34j@users.noreply.github.com> Date: Thu, 23 Mar 2023 17:40:33 +0900 Subject: [PATCH 1/4] fix(gui): fix speaker not updated --- src/so_vits_svc_fork/gui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/so_vits_svc_fork/gui.py b/src/so_vits_svc_fork/gui.py index 6216127e..612a72e2 100644 --- a/src/so_vits_svc_fork/gui.py +++ b/src/so_vits_svc_fork/gui.py @@ -442,7 +442,7 @@ def apply_preset(name: str) -> None: browser.update() else: LOG.warning(f"Browser {browser} is not a FileBrowse") - elif event == "add_preset": + if event == "add_preset": presets = add_preset( values["preset_name"], {key: values[key] for key in PRESET_KEYS} ) From 13c770c0d286850c2b130aba166a70a9110b2e2d Mon Sep 17 00:00:00 2001 From: 34j <55338215+34j@users.noreply.github.com> Date: Thu, 23 Mar 2023 17:41:22 +0900 Subject: [PATCH 2/4] fix(gui): fix devices not updated --- src/so_vits_svc_fork/gui.py | 47 ++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/src/so_vits_svc_fork/gui.py b/src/so_vits_svc_fork/gui.py index 612a72e2..99394bea 100644 --- a/src/so_vits_svc_fork/gui.py +++ b/src/so_vits_svc_fork/gui.py @@ -54,13 +54,19 @@ def delete_preset(name: str) -> dict: return load_presets() -def main(): - sg.theme("Dark") - model_candidates = list(sorted(Path("./logs/44k/").glob("G_*.pth"))) - +def get_devices(update: bool = True) -> tuple[list[str], list[str]]: + if update: + sd._terminate() + sd._initialize() devices = sd.query_devices() input_devices = [d["name"] for d in devices if d["max_input_channels"] > 0] output_devices = [d["name"] for d in devices if d["max_output_channels"] > 0] + return input_devices, output_devices + + +def main(): + sg.theme("Dark") + model_candidates = list(sorted(Path("./logs/44k/").glob("G_*.pth"))) frame_contents = { "Paths": [ @@ -278,9 +284,8 @@ def main(): sg.Push(), sg.Combo( key="input_device", - values=input_devices, + values=[], size=(20, 1), - default_value=input_devices[0], ), ], [ @@ -288,9 +293,8 @@ def main(): sg.Push(), sg.Combo( key="output_device", - values=output_devices, + values=[], size=(20, 1), - default_value=output_devices[0], ), ], [ @@ -401,11 +405,31 @@ def update_speaker() -> None: config_path = Path(values["config_path"]) if config_path.exists() and config_path.is_file(): hp = utils.get_hparams_from_file(values["config_path"]) - LOG.info(f"Loaded config from {values['config_path']}") + LOG.debug(f"Loaded config from {values['config_path']}") window["speaker"].update( values=list(hp.__dict__["spk"].keys()), set_to_index=0 ) + def update_devices() -> None: + input_devices, output_devices = get_devices() + window["input_device"].update( + values=input_devices, value=values["input_device"] + ) + window["output_device"].update( + values=output_devices, value=values["output_device"] + ) + input_default, output_default = sd.default.device + if values["input_device"] not in input_devices: + window["input_device"].update( + values=input_devices, + set_to_index=0 if input_default is None else input_default - 1, + ) + if values["output_device"] not in output_devices: + window["output_device"].update( + values=output_devices, + set_to_index=0 if output_default is None else output_default - 1, + ) + PRESET_KEYS = [ key for key in values.keys() @@ -416,8 +440,8 @@ def apply_preset(name: str) -> None: for key, value in load_presets()[name].items(): if key in PRESET_KEYS: window[key].update(value) + values[key] = value - update_speaker() default_name = list(load_presets().keys())[0] apply_preset(default_name) window["presets"].update(default_name) @@ -425,11 +449,12 @@ def apply_preset(name: str) -> None: with ProcessPool(max_workers=1) as pool: future: None | ProcessFuture = None while True: - event, values = window.read(100) + event, values = window.read(500) if event == sg.WIN_CLOSED: break if not event == sg.EVENT_TIMEOUT: LOG.info(f"Event {event}, values {values}") + update_devices() if event.endswith("_path"): for name in window.AllKeysDict: if str(name).endswith("_browse"): From 510d2039d4d3d4de43d22e868655d3f214b2ec11 Mon Sep 17 00:00:00 2001 From: 34j <55338215+34j@users.noreply.github.com> Date: Thu, 23 Mar 2023 17:42:33 +0900 Subject: [PATCH 3/4] chore(__main__): log current version --- src/so_vits_svc_fork/__main__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/so_vits_svc_fork/__main__.py b/src/so_vits_svc_fork/__main__.py index 6aca80b8..db09193c 100644 --- a/src/so_vits_svc_fork/__main__.py +++ b/src/so_vits_svc_fork/__main__.py @@ -18,8 +18,16 @@ import torch from rich.logging import RichHandler +from so_vits_svc_fork import __version__ + +LOG = getLogger(__name__) +LOGGER_INIT = False + def init_logger() -> None: + global LOGGER_INIT + if LOGGER_INIT: + return IN_COLAB = os.getenv("COLAB_RELEASE_TAG") IS_TEST = "test" in Path(__file__).parent.stem @@ -36,10 +44,11 @@ def init_logger() -> None: if IS_TEST: LOG.debug("Test mode is on.") + LOG.info(f"Version: {__version__}") + LOGGER_INIT = True -init_logger() -LOG = getLogger(__name__) +init_logger() class RichHelpFormatter(click.HelpFormatter): From 2b8d46e21c444dd86657d7f5433cc73c4d64d0e5 Mon Sep 17 00:00:00 2001 From: 34j <55338215+34j@users.noreply.github.com> Date: Thu, 23 Mar 2023 17:43:17 +0900 Subject: [PATCH 4/4] chore(default_gui_presets): add use_gpu --- src/so_vits_svc_fork/default_gui_presets.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/so_vits_svc_fork/default_gui_presets.json b/src/so_vits_svc_fork/default_gui_presets.json index 6b04718e..bb6df99f 100644 --- a/src/so_vits_svc_fork/default_gui_presets.json +++ b/src/so_vits_svc_fork/default_gui_presets.json @@ -14,7 +14,8 @@ "additional_infer_before_seconds": 0.15, "additional_infer_after_seconds": 0.1, "realtime_algorithm": "1 (Divide constantly)", - "passthrough_original": false + "passthrough_original": false, + "use_gpu": true }, "Default VC (CPU)": { "silence_threshold": -35.0, @@ -67,7 +68,8 @@ "additional_infer_before_seconds": 0.05, "additional_infer_after_seconds": 0.05, "realtime_algorithm": "1 (Divide constantly)", - "passthrough_original": false + "passthrough_original": false, + "use_gpu": true }, "Default File": { "silence_threshold": -35.0,