From dcdcf8516c19db80a74f588e3d818e9d74fdc363 Mon Sep 17 00:00:00 2001 From: tigi6346 Date: Sat, 11 Mar 2023 03:28:04 +0000 Subject: [PATCH] master (#112) Fixes Gradio bugging out when attempting to load a missing train.json. Reviewed-on: https://git.ecker.tech/mrq/ai-voice-cloning/pulls/112 Co-authored-by: tigi6346 Co-committed-by: tigi6346 --- src/webui.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) mode change 100755 => 100644 src/webui.py diff --git a/src/webui.py b/src/webui.py old mode 100755 new mode 100644 index 50128b7..1816f14 --- a/src/webui.py +++ b/src/webui.py @@ -218,9 +218,19 @@ def import_training_settings_proxy( voice ): messages = [] injson = f'./training/{voice}/train.json' statedir = f'./training/{voice}/finetune/training_state/' + output = {} - with open(injson, 'r', encoding="utf-8") as f: - settings = json.loads(f.read()) + try: + with open(injson, 'r', encoding="utf-8") as f: + settings = json.loads(f.read()) + except: + messages.append(f"Error import /{voice}/train.json") + + for k in TRAINING_SETTINGS: + output[k] = TRAINING_SETTINGS[k].value + + output = list(output.values()) + return output[:-1] + ["\n".join(messages)] if os.path.isdir(statedir): resumes = sorted([int(d[:-6]) for d in os.listdir(statedir) if d[-6:] == ".state" ])