Jofthomas HF staff commited on
Commit
5db6bc1
1 Parent(s): 8c94603

Update coqui.py

Browse files
Files changed (1) hide show
  1. coqui.py +6 -4
coqui.py CHANGED
@@ -51,6 +51,10 @@ ModelManager().download_model(model_name)
51
  model_path = os.path.join(get_user_data_dir("tts"), model_name.replace("/", "--"))
52
  print("XTTS downloaded")
53
 
 
 
 
 
54
  config = XttsConfig()
55
  config.load_json(os.path.join(model_path, "config.json"))
56
 
@@ -58,11 +62,10 @@ model = Xtts.init_from_config(config)
58
  checkpoint_path = os.path.join(model_path, "model.pth")
59
  vocab_path = os.path.join(model_path, "vocab.json")
60
 
61
- print("config : ",config)
62
  if not os.path.exists(checkpoint_path):
63
- print(f"Checkpoint file not found at {checkpoint_path}")
64
  if not os.path.exists(vocab_path):
65
- print(f"Vocab file not found at {vocab_path}")
66
 
67
  model.load_checkpoint(
68
  config,
@@ -73,7 +76,6 @@ model.load_checkpoint(
73
  )
74
  model.cuda()
75
 
76
-
77
  # This is for debugging purposes only
78
  DEVICE_ASSERT_DETECTED = 0
79
  DEVICE_ASSERT_PROMPT = None
 
51
  model_path = os.path.join(get_user_data_dir("tts"), model_name.replace("/", "--"))
52
  print("XTTS downloaded")
53
 
54
+ # Ensure the model directory and files have the correct permissions
55
+ if not os.access(model_path, os.W_OK):
56
+ raise PermissionError(f"Write permission denied for model directory: {model_path}")
57
+
58
  config = XttsConfig()
59
  config.load_json(os.path.join(model_path, "config.json"))
60
 
 
62
  checkpoint_path = os.path.join(model_path, "model.pth")
63
  vocab_path = os.path.join(model_path, "vocab.json")
64
 
 
65
  if not os.path.exists(checkpoint_path):
66
+ raise FileNotFoundError(f"Checkpoint file not found at {checkpoint_path}")
67
  if not os.path.exists(vocab_path):
68
+ raise FileNotFoundError(f"Vocab file not found at {vocab_path}")
69
 
70
  model.load_checkpoint(
71
  config,
 
76
  )
77
  model.cuda()
78
 
 
79
  # This is for debugging purposes only
80
  DEVICE_ASSERT_DETECTED = 0
81
  DEVICE_ASSERT_PROMPT = None