File size: 3,267 Bytes
c22e108
eb11b36
49e40f5
19c3b3d
15e6d4e
5c7a3e7
19c3b3d
2619293
49e40f5
e80d726
 
 
 
 
49e40f5
 
 
4cbf7f0
 
49e40f5
 
 
 
557d2bd
49e40f5
4320a3c
 
5c5556c
 
 
5b8a969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49431c8
49e40f5
 
3f2ae83
49e40f5
 
 
 
4cbf7f0
19c3b3d
5b8a969
9739936
50c1e8b
9739936
5b8a969
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
FROM python:3.10

# Definir HOME y rutas de caché para Hugging Face
WORKDIR /home/user/app
ENV HOME="/tmp"
ENV HF_HOME="/tmp/.cache/huggingface"
ENV OMP_NUM_THREADS=1

# Configuración de Git vía variables de entorno (sin .gitconfig)
ENV GIT_AUTHOR_NAME="sob111"
ENV GIT_AUTHOR_EMAIL="[email protected]"
ENV GIT_COMMITTER_NAME="sob111"
ENV GIT_COMMITTER_EMAIL="[email protected]"

# Instalar dependencias del sistema
RUN apt-get update && apt-get install -y \
    git wget ffmpeg libsndfile1 unzip build-essential \
    && rm -rf /var/lib/apt/lists/*

# Instalar dependencias Python
COPY requirements.txt .
RUN pip install --upgrade pip \
    && pip install --no-cache-dir -r requirements.txt

# Instalar Coqui TTS en editable mode desde v0.22.0
RUN git clone --branch v0.22.0 https://github.com/coqui-ai/TTS.git /home/user/TTS \
    && cd /home/user/TTS \
    && git submodule update --init --recursive \
    && pip install --no-cache-dir -e .

# 🔧 Crear sitecustomize que simula numba (shim) y parchea librosa
RUN cat > /usr/local/lib/python3.10/site-packages/sitecustomize.py <<'PY'
import sys
import types
import os

# Asegurar cache de numba
NUMBA_CACHE = "/tmp/numba_cache"
try:
    os.makedirs(NUMBA_CACHE, exist_ok=True)
    os.chmod(NUMBA_CACHE, 0o777)
except Exception:
    pass

# Crear un shim de numba si no existe
if "numba" not in sys.modules:
    shim = types.ModuleType("numba")
    shim.__file__ = "<numba_shim>"

    def _identity_decorator(*d_args, **d_kwargs):
        def _decorator(func):
            return func
        if len(d_args) == 1 and callable(d_args[0]):
            return d_args[0]
        return _decorator

    shim.jit = _identity_decorator
    shim.njit = _identity_decorator
    shim.vectorize = _identity_decorator
    shim.guvectorize = _identity_decorator
    shim.generated_jit = _identity_decorator
    shim.stencil = _identity_decorator

    np_module = types.SimpleNamespace()
    ufunc = types.SimpleNamespace()
    decorators = types.SimpleNamespace()
    decorators.vectorize = _identity_decorator
    decorators.guvectorize = _identity_decorator
    decorators.wrap = _identity_decorator
    ufunc.decorators = decorators
    np_module.ufunc = ufunc
    shim.np = np_module

    shim.config = types.SimpleNamespace()
    shim.core = types.SimpleNamespace()
    shim.core.decorators = types.SimpleNamespace()
    shim.core.decorators.jit = _identity_decorator

    sys.modules["numba"] = shim
    sys.modules["numba.np"] = types.SimpleNamespace(ufunc=types.SimpleNamespace(decorators=decorators))
    sys.modules["numba.np.ufunc"] = types.SimpleNamespace(decorators=decorators)
    sys.modules["numba.np.ufunc.decorators"] = decorators

# Parche opcional librosa.magphase
try:
    import librosa
    try:
        from librosa.core import spectrum
        librosa.magphase = getattr(spectrum, "magphase", None)
    except Exception:
        pass
except Exception:
    pass
PY

# Crear directorio de salida para checkpoints
RUN mkdir -p /tmp/output_model

# Copiar el proyecto
COPY . .

# Verificar instalación
RUN pip show TTS

# CMD por defecto (puedes cambiarlo en tu Space)
CMD ["python", "finetune_xtts_hf.py"]
#CMD ["python", "app.py"]
#CMD ["tail", "-f", "/dev/null"]