Spaces:
Sleeping

mossttsnano / Dockerfile
michdubai's picture
Update Dockerfile
0e32e19 verified
Raw History Blame Contribute Delete
1.24 kB
FROM python:3.10-slim
RUN apt-get update && apt-get install -y \
build-essential cmake git wget \
libopenblas-dev libsentencepiece-dev libsndfile1 ffmpeg \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Clone and get weights
RUN git clone https://github.com/kdrkdrkdr/MossTTS-Nano.c.git .
RUN wget https://github.com/kdrkdrkdr/MossTTS-Nano.c/releases/download/model/model.bin
# --- LINUX COMPILATION ---
# Create Linux-compatible assembly file for the weights
RUN printf '.section .data\n.global weights_data\n.global weights_size\n.align 4\nweights_data:\n.incbin "model.bin"\nweights_size:\n.quad . - weights_data\n' > embed_linux.s
# Compile the library for Linux (.so)
RUN g++ -c -fPIC sentencepiece.cpp -O2 -std=c++17
RUN gcc -c -fPIC nanotts.c tensor.c ops.c tts.c codec.c prompt.c audio.c \
-O2 -std=c11 -D_GNU_SOURCE -DUSE_OPENBLAS -DEMBED_WEIGHTS
RUN as -o embed_weights.o embed_linux.s
# Link everything into libnanotts.so
RUN g++ -shared -o libnanotts.so *.o -lopenblas -lsentencepiece -lpthread -lm
# Install Python dependencies
RUN pip install fastapi uvicorn pydub numpy python-multipart
COPY server.py .
ENV PORT=7860
EXPOSE 7860
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]