Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gui): better error handling #85

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 45 additions & 36 deletions src/so_vits_svc_fork/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,35 +505,38 @@ def apply_preset(name: str) -> None:
if not input_path.exists() or not input_path.is_file():
LOG.warning(f"Input path {input_path} does not exist.")
continue
infer(
model_path=Path(values["model_path"]),
config_path=Path(values["config_path"]),
input_path=input_path,
output_path=output_path,
speaker=values["speaker"],
cluster_model_path=Path(values["cluster_model_path"])
if values["cluster_model_path"]
else None,
transpose=values["transpose"],
auto_predict_f0=values["auto_predict_f0"],
cluster_infer_ratio=values["cluster_infer_ratio"],
noise_scale=values["noise_scale"],
db_thresh=values["silence_threshold"],
pad_seconds=values["pad_seconds"],
absolute_thresh=values["absolute_thresh"],
chunk_seconds=values["chunk_seconds"],
device="cpu"
if not values["use_gpu"]
else (
"cuda"
if torch.cuda.is_available()
else "mps"
if torch.backends.mps.is_available()
else "cpu"
),
)
if values["auto_play"]:
pool.schedule(play_audio, args=[output_path])
try:
infer(
model_path=Path(values["model_path"]),
config_path=Path(values["config_path"]),
input_path=input_path,
output_path=output_path,
speaker=values["speaker"],
cluster_model_path=Path(values["cluster_model_path"])
if values["cluster_model_path"]
else None,
transpose=values["transpose"],
auto_predict_f0=values["auto_predict_f0"],
cluster_infer_ratio=values["cluster_infer_ratio"],
noise_scale=values["noise_scale"],
db_thresh=values["silence_threshold"],
pad_seconds=values["pad_seconds"],
absolute_thresh=values["absolute_thresh"],
chunk_seconds=values["chunk_seconds"],
device="cpu"
if not values["use_gpu"]
else (
"cuda"
if torch.cuda.is_available()
else "mps"
if torch.backends.mps.is_available()
else "cpu"
),
)
if values["auto_play"]:
pool.schedule(play_audio, args=[output_path])
except Exception as e:
LOG.exception(e)
elif event == "play_input":
if Path(values["input_path"]).exists():
pool.schedule(play_audio, args=[Path(values["input_path"])])
Expand Down Expand Up @@ -582,15 +585,21 @@ def apply_preset(name: str) -> 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",
)
try:
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",
)
except Exception as e:
LOG.exception(e)
if future is not None and future.done():
LOG.error("Error in realtime: ")
LOG.exception(future.exception())
try:
future.result()
except Exception as e:
LOG.exception(e)
future = None
if future:
future.cancel()
Expand Down