File size: 1,311 Bytes
2b26be4
 
 
1df52bd
 
2b26be4
 
 
 
1df52bd
b403299
 
2b26be4
1df52bd
 
 
 
 
 
 
 
03bb1fc
 
1df52bd
b403299
1df52bd
 
2b26be4
1df52bd
2b26be4
 
 
 
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
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 FIX ---
# We create a 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)
# Note: We remove -DEMBED_WEIGHTS from CFLAGS if we want to load from file, 
# but since the code expects embedded, we fix the labels to match Linux convention.
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

RUN pip install gradio numpy pydub
COPY app.py .

ENV GRADIO_SERVER_NAME="0.0.0.0"
CMD ["python", "app.py"]