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"]