Repository: voicepaw/so-vits-svc-fork

Issue:
ONNX not working
**Describe the bug**
Onnx code is dead and not working

**To Reproduce**
`svc onnx`

**Additional context**
Add any other context about the problem here.



Discussion:

Resolving patch:
diff --git a/src/so_vits_svc_fork/__main__.py b/src/so_vits_svc_fork/__main__.py
--- a/src/so_vits_svc_fork/__main__.py
+++ b/src/so_vits_svc_fork/__main__.py
@@ -545,14 +545,44 @@ def clean():
 
 
 @cli.command
-@click.option("-i", "--input-path", type=click.Path(exists=True), help="model path")
-@click.option("-o", "--output-path", type=click.Path(), help="onnx model path to save")
-@click.option("-c", "--config-path", type=click.Path(), help="config path")
-@click.option("-d", "--device", type=str, default="cpu", help="torch device")
+@click.option(
+    "-i",
+    "--input-path",
+    type=click.Path(exists=True),
+    help="model path",
+    default=Path("./logs/44k/"),
+)
+@click.option(
+    "-o",
+    "--output-path",
+    type=click.Path(),
+    help="onnx model path to save",
+    default=None,
+)
+@click.option(
+    "-c",
+    "--config-path",
+    type=click.Path(),
+    help="config path",
+    default=Path("./configs/44k/config.json"),
+)
+@click.option(
+    "-d",
+    "--device",
+    type=str,
+    default="cpu",
+    help="device to use",
+)
 def onnx(input_path: Path, output_path: Path, config_path: Path, device: str) -> None:
     """Export model to onnx"""
     input_path = Path(input_path)
+    if input_path.is_dir():
+        input_path = list(input_path.glob("*.pth"))[0]
+    if output_path is None:
+        output_path = input_path.with_suffix(".onnx")
     output_path = Path(output_path)
+    if output_path.is_dir():
+        output_path = output_path / (input_path.stem + ".onnx")
     config_path = Path(config_path)
     device_ = torch.device(device)
     from .onnx_export import onnx_export
diff --git a/src/so_vits_svc_fork/gui.py b/src/so_vits_svc_fork/gui.py
--- a/src/so_vits_svc_fork/gui.py
+++ b/src/so_vits_svc_fork/gui.py
@@ -145,7 +145,8 @@ def main():
                 sg.Text(
                     "Pitch (12 = 1 octave)\n"
                     "ADJUST THIS based on your voice\n"
-                    "when Auto predict F0 is turned off."
+                    "when Auto predict F0 is turned off.",
+                    size=(None, 4),
                 ),
                 sg.Push(),
                 sg.Slider(
@@ -392,6 +393,8 @@ def main():
                 sg.Button("Infer", key="infer"),
                 sg.Button("(Re)Start Voice Changer", key="start_vc"),
                 sg.Button("Stop Voice Changer", key="stop_vc"),
+                sg.Push(),
+                sg.Button("ONNX Export", key="onnx_export"),
             ],
         ]
     )
@@ -452,10 +455,12 @@ def apply_preset(name: str) -> None:
     apply_preset(default_name)
     window["presets"].update(default_name)
     del default_name
+    update_speaker()
+    update_devices()
     with ProcessPool(max_workers=1) as pool:
         future: None | ProcessFuture = None
         while True:
-            event, values = window.read(500)
+            event, values = window.read(200)
             if event == sg.WIN_CLOSED:
                 break
             if not event == sg.EVENT_TIMEOUT:
@@ -473,6 +478,10 @@ def apply_preset(name: str) -> None:
                             browser.update()
                         else:
                             LOG.warning(f"Browser {browser} is not a FileBrowse")
+            window["transpose"].update(
+                disabled=values["auto_predict_f0"],
+                visible=not values["auto_predict_f0"],
+            )
             if event == "add_preset":
                 presets = add_preset(
                     values["preset_name"], {key: values[key] for key in PRESET_KEYS}
@@ -570,8 +579,18 @@ def apply_preset(name: str) -> None:
                 if future:
                     future.cancel()
                     future = None
+            elif event == "onnx_export":
+                from .onnx_export import onnx_export
+
+                onnx_export(
+                    input_path=Path(values["model_path"]),
+                    output_path=Path(values["model_path"]).with_suffix(".onnx"),
+                    config_path=Path(values["config_path"]),
+                    device="cpu",
+                )
             if future is not None and future.done():
-                LOG.error(f"Error in realtime: {future.exception()}")
+                LOG.error("Error in realtime: ")
+                LOG.exception(future.exception())
                 future = None
         if future:
             future.cancel()
diff --git a/src/so_vits_svc_fork/onnxexport/model_onnx.py b/src/so_vits_svc_fork/onnxexport/model_onnx.py
--- a/src/so_vits_svc_fork/onnxexport/model_onnx.py
+++ b/src/so_vits_svc_fork/onnxexport/model_onnx.py
@@ -4,13 +4,11 @@
 from torch.nn import functional as F
 from torch.nn.utils import spectral_norm, weight_norm
 
-from so_vits_svc_fork import modules as attentions
-from so_vits_svc_fork import modules as commons
-from so_vits_svc_fork import modules as modules
-from so_vits_svc_fork import utils
-from so_vits_svc_fork.modules.commons import get_padding
-from so_vits_svc_fork.utils import f0_to_coarse
-from so_vits_svc_fork.vdecoder.hifigan.models import Generator
+from .. import utils
+from ..modules import attentions, commons, modules
+from ..modules.commons import get_padding
+from ..utils import f0_to_coarse
+from ..vdecoder.hifigan.models import Generator
 
 
 class ResidualCouplingBlock(nn.Module):


Test patch: