Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,6 @@ import time
|
|
8 |
import torch
|
9 |
import torchaudio
|
10 |
|
11 |
-
|
12 |
#download for mecab
|
13 |
os.system('python -m unidic download')
|
14 |
|
@@ -35,17 +34,13 @@ from TTS.utils.generic_utils import get_user_data_dir
|
|
35 |
|
36 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
37 |
|
38 |
-
from huggingface_hub import
|
39 |
import os
|
40 |
-
from TTS.utils.manage import get_user_data_dir
|
41 |
|
42 |
# Autenticación con la API de Hugging Face
|
43 |
-
api = HfApi(token=HF_TOKEN)
|
44 |
repo_id = "Blakus/XTTS_custom"
|
45 |
-
|
46 |
-
# Definir el directorio local usando la misma ruta que el código original
|
47 |
-
model_name = "tts_models/multilingual/multi-dataset/xtts_v2"
|
48 |
-
local_dir = os.path.join(get_user_data_dir("tts"), model_name.replace("/", "--"))
|
49 |
|
50 |
# Crear el directorio si no existe
|
51 |
os.makedirs(local_dir, exist_ok=True)
|
@@ -56,12 +51,8 @@ files_to_download = ["config.json", "model.pth", "vocab.json"]
|
|
56 |
# Descargar cada archivo del repositorio
|
57 |
for file_name in files_to_download:
|
58 |
print(f"Downloading {file_name} from {repo_id}")
|
59 |
-
|
60 |
-
|
61 |
-
filename=file_name,
|
62 |
-
local_dir=local_dir,
|
63 |
-
repo_type="model" # Puede ser 'model', 'dataset' o 'space'
|
64 |
-
)
|
65 |
|
66 |
# Cargar configuración y modelo
|
67 |
config_path = os.path.join(local_dir, "config.json")
|
@@ -77,12 +68,10 @@ model.load_checkpoint(
|
|
77 |
checkpoint_path=checkpoint_path,
|
78 |
vocab_path=vocab_path,
|
79 |
eval=True,
|
80 |
-
use_deepspeed=False, #
|
81 |
)
|
82 |
|
83 |
-
# No transfieras el modelo a la GPU
|
84 |
-
# model.cuda()
|
85 |
-
|
86 |
print("Modelo cargado en CPU")
|
87 |
|
88 |
# This is for debugging purposes only
|
|
|
8 |
import torch
|
9 |
import torchaudio
|
10 |
|
|
|
11 |
#download for mecab
|
12 |
os.system('python -m unidic download')
|
13 |
|
|
|
34 |
|
35 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
36 |
|
37 |
+
from huggingface_hub import hf_hub_download
|
38 |
import os
|
39 |
+
from TTS.utils.manage import get_user_data_dir
|
40 |
|
41 |
# Autenticación con la API de Hugging Face
|
|
|
42 |
repo_id = "Blakus/XTTS_custom"
|
43 |
+
local_dir = os.path.join(get_user_data_dir("tts"), "tts_models--multilingual--multi-dataset--xtts_v2")
|
|
|
|
|
|
|
44 |
|
45 |
# Crear el directorio si no existe
|
46 |
os.makedirs(local_dir, exist_ok=True)
|
|
|
51 |
# Descargar cada archivo del repositorio
|
52 |
for file_name in files_to_download:
|
53 |
print(f"Downloading {file_name} from {repo_id}")
|
54 |
+
local_file_path = os.path.join(local_dir, file_name)
|
55 |
+
hf_hub_download(repo_id=repo_id, filename=file_name, local_dir=local_dir)
|
|
|
|
|
|
|
|
|
56 |
|
57 |
# Cargar configuración y modelo
|
58 |
config_path = os.path.join(local_dir, "config.json")
|
|
|
68 |
checkpoint_path=checkpoint_path,
|
69 |
vocab_path=vocab_path,
|
70 |
eval=True,
|
71 |
+
use_deepspeed=False, # Desactivamos DeepSpeed para ejecución en CPU
|
72 |
)
|
73 |
|
74 |
+
# No transfieras el modelo a la GPU
|
|
|
|
|
75 |
print("Modelo cargado en CPU")
|
76 |
|
77 |
# This is for debugging purposes only
|