ecker commited on
Commit
ed2cf9f
·
1 Parent(s): b6f7aa6

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

Browse files
Files changed (1) hide show
  1. src/utils.py +25 -11
src/utils.py CHANGED
@@ -490,6 +490,17 @@ def stop_training():
490
  training_process.kill()
491
  return "Training cancelled"
492
 
 
 
 
 
 
 
 
 
 
 
 
493
  def prepare_dataset( files, outdir, language=None, progress=None ):
494
  unload_tts()
495
 
@@ -961,17 +972,20 @@ def read_generate_settings(file, read_latents=True):
961
  if isinstance(file, list) and len(file) == 1:
962
  file = file[0]
963
 
964
- if file is not None:
965
- if hasattr(file, 'name'):
966
- file = file.name
967
-
968
- if file[-4:] == ".wav":
969
- metadata = music_tag.load_file(file)
970
- if 'lyrics' in metadata:
971
- j = json.loads(str(metadata['lyrics']))
972
- elif file[-5:] == ".json":
973
- with open(file, 'r') as f:
974
- j = json.load(f)
 
 
 
975
 
976
  if j is None:
977
  print("No metadata found in audio file to read")
 
490
  training_process.kill()
491
  return "Training cancelled"
492
 
493
+ def convert_to_halfp():
494
+ autoregressive_model_path = get_model_path('autoregressive.pth')
495
+ model = torch.load(autoregressive_model_path)
496
+ for k in model:
497
+ if re.findall(r'\.weight$', k):
498
+ print(f"Converting: {k}")
499
+ model[k] = model[k].half()
500
+
501
+ torch.save(model, './models/tortoise/autoregressive_half.pth')
502
+ print('Converted model to half precision: ./models/tortoise/autoregressive_half.pth')
503
+
504
  def prepare_dataset( files, outdir, language=None, progress=None ):
505
  unload_tts()
506
 
 
972
  if isinstance(file, list) and len(file) == 1:
973
  file = file[0]
974
 
975
+ try:
976
+ if file is not None:
977
+ if hasattr(file, 'name'):
978
+ file = file.name
979
+
980
+ if file[-4:] == ".wav":
981
+ metadata = music_tag.load_file(file)
982
+ if 'lyrics' in metadata:
983
+ j = json.loads(str(metadata['lyrics']))
984
+ elif file[-5:] == ".json":
985
+ with open(file, 'r') as f:
986
+ j = json.load(f)
987
+ except Exception as e:
988
+ pass
989
 
990
  if j is None:
991
  print("No metadata found in audio file to read")