Spaces:
Build error
Build error
wrap checking for metadata when adding a voice in case it throws an error
Browse files- 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 |
-
|
| 965 |
-
if
|
| 966 |
-
|
| 967 |
-
|
| 968 |
-
|
| 969 |
-
|
| 970 |
-
|
| 971 |
-
|
| 972 |
-
|
| 973 |
-
|
| 974 |
-
|
|
|
|
|
|
|
|
|
|
| 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")
|