Spaces:
M4xjunior
/
Running on Zero

M4xjunior commited on
Commit
6249865
·
1 Parent(s): cad4e33
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -50,27 +50,27 @@ vocoder = load_vocoder()
50
 
51
 
52
  import os
53
- from huggingface_hub import HfApi
54
-
55
-
56
 
57
  def load_f5tts():
58
- # Carrega o caminho do modelo e o token das variáveis de ambiente
59
- ckpt_path = os.getenv("MODEL_CKPT_PATH", "hf://SWivid/F5-TTS/F5TTS_Base/model_1200000.safetensors")
 
60
  token = os.getenv("HUGGINGFACE_TOKEN")
61
 
62
  # Valida se o token está presente
63
  if not token:
64
  raise ValueError("A variável de ambiente 'HUGGINGFACE_TOKEN' não foi definida.")
65
 
66
- # Carrega o modelo
67
- ckpt_path = cached_path(ckpt_path, use_auth_token=token)
68
 
69
  F5TTS_model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
70
  return load_model(DiT, F5TTS_model_cfg, ckpt_path)
71
 
72
 
73
 
 
74
  def load_e2tts(ckpt_path=str(cached_path("hf://SWivid/E2-TTS/E2TTS_Base/model_1200000.safetensors"))):
75
  E2TTS_model_cfg = dict(dim=1024, depth=24, heads=16, ff_mult=4)
76
  return load_model(UNetT, E2TTS_model_cfg, ckpt_path)
 
50
 
51
 
52
  import os
53
+ from huggingface_hub import hf_hub_download
 
 
54
 
55
  def load_f5tts():
56
+ # Carrega o caminho do repositório e o nome do arquivo das variáveis de ambiente
57
+ repo_id = os.getenv("MODEL_REPO_ID", "SWivid/F5-TTS/F5TTS_Base")
58
+ filename = os.getenv("MODEL_FILENAME", "model_1200000.safetensors")
59
  token = os.getenv("HUGGINGFACE_TOKEN")
60
 
61
  # Valida se o token está presente
62
  if not token:
63
  raise ValueError("A variável de ambiente 'HUGGINGFACE_TOKEN' não foi definida.")
64
 
65
+ # Faz o download do modelo do repositório privado
66
+ ckpt_path = hf_hub_download(repo_id=repo_id, filename=filename, use_auth_token=token)
67
 
68
  F5TTS_model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
69
  return load_model(DiT, F5TTS_model_cfg, ckpt_path)
70
 
71
 
72
 
73
+
74
  def load_e2tts(ckpt_path=str(cached_path("hf://SWivid/E2-TTS/E2TTS_Base/model_1200000.safetensors"))):
75
  E2TTS_model_cfg = dict(dim=1024, depth=24, heads=16, ff_mult=4)
76
  return load_model(UNetT, E2TTS_model_cfg, ckpt_path)