Skip to content

Commit

Permalink
fix(gui): show errors raised in inference (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
34j authored Apr 15, 2023
1 parent aa3d1c7 commit 99833c5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/so_vits_svc_fork/gui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import json
from copy import copy
from logging import getLogger
from pathlib import Path

Expand Down Expand Up @@ -514,6 +515,7 @@ def apply_preset(name: str) -> None:
update_devices()
with ProcessPool(max_workers=1) as pool:
future: None | ProcessFuture = None
infer_futures: set[ProcessFuture] = set()
while True:
event, values = window.read(200)
if event == sg.WIN_CLOSED:
Expand Down Expand Up @@ -598,6 +600,7 @@ def apply_preset(name: str) -> None:
window, input_path, values["auto_play"], output_path
)
)
infer_futures.add(infer_future)
except Exception as e:
LOG.exception(e)
elif event == "play_input":
Expand Down Expand Up @@ -676,6 +679,14 @@ def apply_preset(name: str) -> None:
except Exception as e:
LOG.exception(e)
future = None
for future in copy(infer_futures):
if future.done():
LOG.error("Error in inference: ")
try:
future.result()
except Exception as e:
LOG.exception(e)
infer_futures.remove(future)
if future:
future.cancel()
window.close()

0 comments on commit 99833c5

Please sign in to comment.