ecker commited on
Commit
dc1902b
·
1 Parent(s): 7978823

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

Browse files
Files changed (1) hide show
  1. src/utils.py +8 -12
src/utils.py CHANGED
@@ -268,20 +268,15 @@ def generate(**kwargs):
268
 
269
  if latents and "latents" not in info:
270
  voice = info['voice']
271
- latents_path = f'{get_voice_dir()}/{voice}/cond_latents.pth'
 
 
 
272
 
273
  if voice == "random" or voice == "microphone":
274
  if latents and settings is not None and settings['conditioning_latents']:
275
- dir = f'{get_voice_dir()}/{voice}/'
276
- if not os.path.isdir(dir):
277
- os.makedirs(dir, exist_ok=True)
278
- latents_path = f'{dir}/cond_latents.pth'
279
  torch.save(conditioning_latents, latents_path)
280
- else:
281
- if settings is not None and "model_hash" in settings:
282
- latents_path = f'{get_voice_dir()}/{voice}/cond_latents_{settings["model_hash"][:8]}.pth'
283
- else:
284
- latents_path = f'{get_voice_dir()}/{voice}/cond_latents_{tts.autoregressive_model_hash[:8]}.pth'
285
 
286
  if latents_path and os.path.exists(latents_path):
287
  try:
@@ -1526,10 +1521,11 @@ def import_voices(files, saveAs=None, progress=None):
1526
  print(f"Imported voice to {path}")
1527
 
1528
  def get_voice_list(dir=get_voice_dir(), append_defaults=False):
 
1529
  os.makedirs(dir, exist_ok=True)
1530
- 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 ])
1531
  if append_defaults:
1532
- res = res + ["random", "microphone"]
1533
  return res
1534
 
1535
  def get_autoregressive_models(dir="./models/finetunes/", prefixed=False):
 
268
 
269
  if latents and "latents" not in info:
270
  voice = info['voice']
271
+ model_hash = settings["model_hash"][:8] if settings is not None and "model_hash" in settings else tts.autoregressive_model_hash[:8]
272
+
273
+ dir = f'{get_voice_dir()}/{voice}/'
274
+ latents_path = f'{dir}/cond_latents_{model_hash}.pth'
275
 
276
  if voice == "random" or voice == "microphone":
277
  if latents and settings is not None and settings['conditioning_latents']:
278
+ os.makedirs(dir, exist_ok=True)
 
 
 
279
  torch.save(conditioning_latents, latents_path)
 
 
 
 
 
280
 
281
  if latents_path and os.path.exists(latents_path):
282
  try:
 
1521
  print(f"Imported voice to {path}")
1522
 
1523
  def get_voice_list(dir=get_voice_dir(), append_defaults=False):
1524
+ defaults = [ "random", "microphone" ]
1525
  os.makedirs(dir, exist_ok=True)
1526
+ 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 ])
1527
  if append_defaults:
1528
+ res = res + defaults
1529
  return res
1530
 
1531
  def get_autoregressive_models(dir="./models/finetunes/", prefixed=False):