cleanup block that makes embedding latents for random/microphone happen, remove builtin voice options from voice list to avoid duplicates

This commit is contained in:
mrq 2023-03-09 04:23:36 +00:00
parent 797882336b
commit dc1902b91c

View File

@ -268,20 +268,15 @@ def generate(**kwargs):
if latents and "latents" not in info: if latents and "latents" not in info:
voice = info['voice'] voice = info['voice']
latents_path = f'{get_voice_dir()}/{voice}/cond_latents.pth' model_hash = settings["model_hash"][:8] if settings is not None and "model_hash" in settings else tts.autoregressive_model_hash[:8]
dir = f'{get_voice_dir()}/{voice}/'
latents_path = f'{dir}/cond_latents_{model_hash}.pth'
if voice == "random" or voice == "microphone": if voice == "random" or voice == "microphone":
if latents and settings is not None and settings['conditioning_latents']: if latents and settings is not None and settings['conditioning_latents']:
dir = f'{get_voice_dir()}/{voice}/' os.makedirs(dir, exist_ok=True)
if not os.path.isdir(dir):
os.makedirs(dir, exist_ok=True)
latents_path = f'{dir}/cond_latents.pth'
torch.save(conditioning_latents, latents_path) torch.save(conditioning_latents, latents_path)
else:
if settings is not None and "model_hash" in settings:
latents_path = f'{get_voice_dir()}/{voice}/cond_latents_{settings["model_hash"][:8]}.pth'
else:
latents_path = f'{get_voice_dir()}/{voice}/cond_latents_{tts.autoregressive_model_hash[:8]}.pth'
if latents_path and os.path.exists(latents_path): if latents_path and os.path.exists(latents_path):
try: try:
@ -1526,10 +1521,11 @@ def import_voices(files, saveAs=None, progress=None):
print(f"Imported voice to {path}") print(f"Imported voice to {path}")
def get_voice_list(dir=get_voice_dir(), append_defaults=False): def get_voice_list(dir=get_voice_dir(), append_defaults=False):
defaults = [ "random", "microphone" ]
os.makedirs(dir, exist_ok=True) os.makedirs(dir, exist_ok=True)
res = sorted([d for d in os.listdir(dir) if os.path.isdir(os.path.join(dir, d)) and len(os.listdir(os.path.join(dir, d))) > 0 ]) res = sorted([d for d in os.listdir(dir) if d is not in defaults and os.path.isdir(os.path.join(dir, d)) and len(os.listdir(os.path.join(dir, d))) > 0 ])
if append_defaults: if append_defaults:
res = res + ["random", "microphone"] res = res + defaults
return res return res
def get_autoregressive_models(dir="./models/finetunes/", prefixed=False): def get_autoregressive_models(dir="./models/finetunes/", prefixed=False):