forked from coqui-ai/STT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.train
99 lines (80 loc) · 3.33 KB
/
Dockerfile.train
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
# 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:22.02-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 nvcr.io/nvidia/tensorflow:22.02-tf1-py3
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
wget \
libopus0 \
libvorbisfile3 \
libopusfile0 \
libsndfile1 \
sox \
libsox-fmt-mp3 \
python3-venv \
software-properties-common && \
rm -rf /var/lib/apt/lists/*
# For exporting using TFLite
RUN add-apt-repository ppa:deadsnakes/ppa -y
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends \
python3.7 \
python3.7-venv
RUN python3 -m venv --system-site-packages /venv
ENV VIRTUAL_ENV=/venv
# Venv for upstream tensorflow with tflite api
RUN python3.7 -m venv /tflite-venv
ENV PATH="$VIRTUAL_ENV/bin:/tflite-venv/bin:$PATH"
# Make sure pip and its dependencies are up-to-date
RUN pip 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 pip 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
# Pre-built native client tools
RUN LATEST_STABLE_RELEASE=$(curl "https://api.github.com/repos/coqui-ai/STT/releases/latest" | python -c 'import sys; import json; print(json.load(sys.stdin)["tag_name"])') \
bash -c 'curl -L https://github.com/coqui-ai/STT/releases/download/${LATEST_STABLE_RELEASE}/native_client.tflite.Linux.tar.xz | tar -xJvf -'
# 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 pip install --upgrade -e .
# Install coqui_stt_training (inside tf-venv) for exporting models using tflite
RUN /tflite-venv/bin/pip install -e .
# Copy rest of the code and test training
COPY . /code
RUN ./bin/run-ldc93s1.sh && rm -rf ~/.local/share/stt