98 lines
3.3 KiB
Docker
98 lines
3.3 KiB
Docker
# This is a Dockerfile useful for training models with Coqui STT.
|
|
# You can train "acoustic models" with audio + Tensorflow, and
|
|
# you can create "scorers" with text + KenLM.
|
|
|
|
FROM nvcr.io/nvidia/tensorflow:20.06-tf1-py3 AS kenlm-build
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
build-essential cmake libboost-system-dev \
|
|
libboost-thread-dev libboost-program-options-dev \
|
|
libboost-test-dev libeigen3-dev zlib1g-dev \
|
|
libbz2-dev liblzma-dev && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Build KenLM to generate new scorers
|
|
WORKDIR /code
|
|
COPY kenlm /code/kenlm
|
|
RUN cd /code/kenlm && \
|
|
mkdir -p build && \
|
|
cd build && \
|
|
cmake .. && \
|
|
make -j $(nproc) || \
|
|
( echo "ERROR: Failed to build KenLM."; \
|
|
echo "ERROR: Make sure you update the kenlm submodule on host before building this Dockerfile."; \
|
|
echo "ERROR: $ cd STT; git submodule update --init kenlm"; \
|
|
exit 1; )
|
|
|
|
|
|
FROM ubuntu:20.04 AS wget-binaries
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends wget unzip xz-utils && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Tool to convert output graph for inference
|
|
RUN wget --no-check-certificate https://github.com/coqui-ai/STT/releases/download/v0.9.3/convert_graphdef_memmapped_format.linux.amd64.zip -O temp.zip && \
|
|
unzip temp.zip && \
|
|
rm temp.zip
|
|
|
|
RUN wget --no-check-certificate https://github.com/reuben/STT/releases/download/v0.10.0-alpha.1/native_client.tar.xz -O temp.tar.xz && \
|
|
tar -xf temp.tar.xz && \
|
|
rm temp.tar.xz
|
|
|
|
|
|
FROM nvcr.io/nvidia/tensorflow:20.06-tf1-py3
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# We need to purge python3-xdg because
|
|
# it's breaking STT install later with
|
|
# errors about setuptools
|
|
#
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
git \
|
|
wget \
|
|
libopus0 \
|
|
libopusfile0 \
|
|
libsndfile1 \
|
|
sox \
|
|
libsox-fmt-mp3 && \
|
|
apt-get purge -y python3-xdg && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Make sure pip and its dependencies are up-to-date
|
|
RUN pip3 install --upgrade pip wheel setuptools
|
|
|
|
WORKDIR /code
|
|
|
|
COPY native_client /code/native_client
|
|
COPY .git /code/.git
|
|
COPY training/coqui_stt_training/VERSION /code/training/coqui_stt_training/VERSION
|
|
COPY training/coqui_stt_training/GRAPH_VERSION /code/training/coqui_stt_training/GRAPH_VERSION
|
|
|
|
# Build CTC decoder first, to avoid clashes on incompatible versions upgrades
|
|
RUN cd native_client/ctcdecode && make NUM_PROCESSES=$(nproc) bindings
|
|
RUN pip3 install --upgrade native_client/ctcdecode/dist/*.whl
|
|
|
|
COPY setup.py /code/setup.py
|
|
COPY VERSION /code/VERSION
|
|
COPY training /code/training
|
|
# Copy files from previous build stages
|
|
RUN mkdir -p /code/kenlm/build/
|
|
COPY --from=kenlm-build /code/kenlm/build/bin /code/kenlm/build/bin
|
|
COPY --from=wget-binaries /convert_graphdef_memmapped_format /code/convert_graphdef_memmapped_format
|
|
COPY --from=wget-binaries /generate_scorer_package /code/generate_scorer_package
|
|
|
|
# Install STT
|
|
# No need for the decoder since we did it earlier
|
|
# TensorFlow GPU should already be installed on the base image,
|
|
# and we don't want to break that
|
|
RUN DS_NODECODER=y DS_NOTENSORFLOW=y pip3 install --upgrade -e .
|
|
|
|
# Copy rest of the code and test training
|
|
COPY . /code
|
|
RUN ./bin/run-ldc93s1.sh && rm -rf ~/.local/share/stt
|