Skip to content

Commit

Permalink
fix(gui,onnx): fix onnx export and fix gui (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
34j committed Mar 23, 2023
1 parent 34cb0dc commit 3e9a47d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 14 deletions.
Binary file modified docs/_static/gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 34 additions & 4 deletions src/so_vits_svc_fork/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 22 additions & 3 deletions src/so_vits_svc_fork/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"),
],
]
)
Expand Down Expand Up @@ -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:
Expand All @@ -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}
Expand Down Expand Up @@ -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()
Expand Down
12 changes: 5 additions & 7 deletions src/so_vits_svc_fork/onnxexport/model_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 3e9a47d

Please sign in to comment.