wrap checking for metadata when adding a voice in case it throws an error

This commit is contained in:
mrq 2023-02-21 17:35:30 +00:00
parent b6f7aa6264
commit ed2cf9f5ee

View File

@ -490,6 +490,17 @@ def stop_training():
training_process.kill() training_process.kill()
return "Training cancelled" 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 ): def prepare_dataset( files, outdir, language=None, progress=None ):
unload_tts() unload_tts()
@ -961,6 +972,7 @@ def read_generate_settings(file, read_latents=True):
if isinstance(file, list) and len(file) == 1: if isinstance(file, list) and len(file) == 1:
file = file[0] file = file[0]
try:
if file is not None: if file is not None:
if hasattr(file, 'name'): if hasattr(file, 'name'):
file = file.name file = file.name
@ -972,6 +984,8 @@ def read_generate_settings(file, read_latents=True):
elif file[-5:] == ".json": elif file[-5:] == ".json":
with open(file, 'r') as f: with open(file, 'r') as f:
j = json.load(f) j = json.load(f)
except Exception as e:
pass
if j is None: if j is None:
print("No metadata found in audio file to read") print("No metadata found in audio file to read")