MariaKaiser commited on
Commit
187546a
·
verified ·
1 Parent(s): 6788b90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -7
app.py CHANGED
@@ -15,24 +15,38 @@ from huggingface_hub import hf_hub_download
15
  # ------------------------
16
  # Download model files from Hugging Face if not present
17
  # ------------------------
18
- MODEL_DIR = "/tmp/my_model"
19
- os.makedirs(MODEL_DIR, exist_ok=True)
20
- for fname in ["config.json", "vocab.json", "model.pth"]:
21
- hf_hub_download("MariaKaiser/EGTTS_finetuned", filename=fname, cache_dir=MODEL_DIR)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  from TTS.tts.models.xtts import Xtts
24
  from TTS.tts.configs.xtts_config import XttsConfig
25
 
26
  # Load model
27
  config = XttsConfig()
28
- config.load_json(os.path.join(MODEL_DIR, "config.json"))
29
 
30
  model = Xtts.init_from_config(config)
31
  model.load_checkpoint(
32
  config,
33
- checkpoint_dir=MODEL_DIR,
34
  use_deepspeed=False,
35
- vocab_path=os.path.join(MODEL_DIR, "vocab.json")
36
  )
37
  model.to(device)
38
 
 
15
  # ------------------------
16
  # Download model files from Hugging Face if not present
17
  # ------------------------
18
+ MODEL_DIR = "my_model"
19
+ config_path = hf_hub_download(
20
+ repo_id="MariaKaiser/EGTTS_finetuned",
21
+ filename="config.json",
22
+ cache_dir=MODEL_DIR
23
+ )
24
+
25
+ vocab_path = hf_hub_download(
26
+ repo_id="MariaKaiser/EGTTS_finetuned",
27
+ filename="vocab.json",
28
+ cache_dir=MODEL_DIR
29
+ )
30
+
31
+ model_path = hf_hub_download(
32
+ repo_id="MariaKaiser/EGTTS_finetuned",
33
+ filename="model.pth",
34
+ cache_dir=MODEL_DIR
35
+ )
36
 
37
  from TTS.tts.models.xtts import Xtts
38
  from TTS.tts.configs.xtts_config import XttsConfig
39
 
40
  # Load model
41
  config = XttsConfig()
42
+ config.load_json(config_path)
43
 
44
  model = Xtts.init_from_config(config)
45
  model.load_checkpoint(
46
  config,
47
+ checkpoint_dir= os.path.dirname(model_path),
48
  use_deepspeed=False,
49
+ vocab_path= vocab_path
50
  )
51
  model.to(device)
52