forked from UFAL-DSG/alex-asr
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
63 lines (52 loc) · 2.58 KB
/
Dockerfile
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
FROM ubuntu:22.04 AS builder
RUN apt-get update -qq && apt-get install -y \
git bzip2 wget unzip \
g++ gfortran make python2.7 python3 python3-pip \
zlib1g-dev automake autoconf libtool subversion \
libatlas-base-dev sox && pip3 install --upgrade pip
ARG ALEX_ASR_VERSION=8b3cf6588803c54cd1f294cdb76bec133f7e73b9
ARG KALDI_VERSION=d136b18346bee14166b950029405314401fc4a8b
ARG OPENFST_VERSION=1.6.2
WORKDIR /opt/
RUN git clone https://github.com/choko/alex-asr.git \
&& cd alex-asr && mkdir libs \
&& git clone https://github.com/kaldi-asr/kaldi.git libs/kaldi \
&& git clone https://github.com/UFAL-DSG/pyfst.git libs/pyfst
WORKDIR /opt/alex-asr
RUN git checkout ${ALEX_ASR_VERSION} \
&& pip3 install pgen cython pystache pyyaml \
&& cd libs/kaldi \
&& git checkout ${KALDI_VERSION}
WORKDIR /opt/alex-asr/libs/kaldi/tools
RUN sed -e "s/--enable-ngram-fsts/--enable-ngram-fsts --with-pic/g;s/openfst.cs.nyu.edu/openfst.org/g" -i Makefile \
&& OPENFST_VERSION=${OPENFST_VERSION} make -j 4 openfst
RUN sed -i 's@OPENBLAS_VERSION=0.3.7@OPENBLAS_VERSION=0.3.13@;s@python @python3 @' extras/install_openblas.sh && extras/install_openblas.sh
WORKDIR /opt/alex-asr/libs/kaldi/src
RUN ./configure --shared --use-cuda=no --openblas-root=../tools/OpenBLAS/install && make -j 4
WORKDIR /opt/alex-asr
RUN sed -i 's/from collections import Callable/from collections.abc import Callable/' alex_asr/ordereddefaultdict.py && make
ARG VERSION
RUN VERSION=${VERSION:=$(date +%Y%m%d-%H%M%S)} \
&& echo VERSION=$VERSION >> VERSION.env \
&& echo dpkg=alex-asr-${VERSION} >> VERSION.env \
&& python3 setup.py install --root ./alex-asr-${VERSION} \
&& pip3 install webrtcvad --root ./alex-asr-${VERSION}
RUN . ./VERSION.env && echo $VERSION \
&& find ${dpkg} -name '*.so' | xargs strip -S \
&& mkdir -p ${dpkg}/DEBIAN \
&& echo 'Package: alex-asr' >> ${dpkg}/DEBIAN/control \
&& echo "Version: $VERSION" >> ${dpkg}/DEBIAN/control \
&& echo 'Maintainer: Ondrej Klejch' >> ${dpkg}/DEBIAN/control \
&& echo 'Description: AlexASR' >> ${dpkg}/DEBIAN/control \
&& echo 'Architecture: amd64' >> ${dpkg}/DEBIAN/control \
&& dpkg-deb --build ${dpkg}
FROM ubuntu:22.04 AS engine
RUN apt-get update && apt-get install -y libgfortran5 python3 python3-pkg-resources unzip wget
COPY --from=builder /opt/alex-asr/*.deb .
RUN dpkg -i *.deb && rm *.deb && rm -rf /var/lib/apt/lists/*
ARG MODEL_URL
WORKDIR /opt/app
ADD ./demo/download_model.sh .
RUN bash download_model.sh "$MODEL_URL" "/opt/model" && rm /opt/model/model.zip
ADD ./demo/run.py .
CMD python3 -u /opt/app/run.py