From ed2cf9f5ee558c5efb63b17025ae0b25a29bbaa0 Mon Sep 17 00:00:00 2001 From: mrq Date: Tue, 21 Feb 2023 17:35:30 +0000 Subject: [PATCH] wrap checking for metadata when adding a voice in case it throws an error --- src/utils.py | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/utils.py b/src/utils.py index 2d0de77..7cb8c6f 100755 --- a/src/utils.py +++ b/src/utils.py @@ -490,6 +490,17 @@ def stop_training(): training_process.kill() return "Training cancelled" +def convert_to_halfp(): + autoregressive_model_path = get_model_path('autoregressive.pth') + model = torch.load(autoregressive_model_path) + for k in model: + if re.findall(r'\.weight$', k): + print(f"Converting: {k}") + model[k] = model[k].half() + + torch.save(model, './models/tortoise/autoregressive_half.pth') + print('Converted model to half precision: ./models/tortoise/autoregressive_half.pth') + def prepare_dataset( files, outdir, language=None, progress=None ): unload_tts() @@ -961,17 +972,20 @@ def read_generate_settings(file, read_latents=True): if isinstance(file, list) and len(file) == 1: file = file[0] - if file is not None: - if hasattr(file, 'name'): - file = file.name - - if file[-4:] == ".wav": - metadata = music_tag.load_file(file) - if 'lyrics' in metadata: - j = json.loads(str(metadata['lyrics'])) - elif file[-5:] == ".json": - with open(file, 'r') as f: - j = json.load(f) + try: + if file is not None: + if hasattr(file, 'name'): + file = file.name + + if file[-4:] == ".wav": + metadata = music_tag.load_file(file) + if 'lyrics' in metadata: + j = json.loads(str(metadata['lyrics'])) + elif file[-5:] == ".json": + with open(file, 'r') as f: + j = json.load(f) + except Exception as e: + pass if j is None: print("No metadata found in audio file to read")