Skip to content

Commit 0154369

Browse files
committed
Added Dockerfile for example with single master, worker and model
1 parent cfb02e0 commit 0154369

File tree

4 files changed

+149
-0
lines changed

4 files changed

+149
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
FROM debian:8
2+
3+
RUN apt-get update && apt-get install -y \
4+
autoconf \
5+
automake \
6+
bzip2 \
7+
g++ \
8+
git \
9+
gstreamer1.0-plugins-good \
10+
gstreamer1.0-tools \
11+
gstreamer1.0-pulseaudio \
12+
gstreamer1.0-plugins-bad \
13+
gstreamer1.0-plugins-base \
14+
gstreamer1.0-plugins-ugly \
15+
libatlas3-base \
16+
libgstreamer1.0-dev \
17+
libtool-bin \
18+
make \
19+
python2.7 \
20+
python-pip \
21+
python-yaml \
22+
python-simplejson \
23+
python-gi \
24+
subversion \
25+
wget \
26+
zlib1g-dev && \
27+
apt-get clean autoclean && \
28+
apt-get autoremove -y && \
29+
pip install ws4py==0.3.2 && \
30+
pip install tornado && \
31+
ln -s /usr/bin/python2.7 /usr/bin/python ; ln -s -f bash /bin/sh
32+
33+
RUN cd /opt && wget http://www.digip.org/jansson/releases/jansson-2.7.tar.bz2 && \
34+
bunzip2 -c jansson-2.7.tar.bz2 | tar xf - && \
35+
cd jansson-2.7 && \
36+
./configure && make && make check && make install && \
37+
echo "/usr/local/lib" >> /etc/ld.so.conf.d/jansson.conf && ldconfig && \
38+
rm /opt/jansson-2.7.tar.bz2 && rm -rf /opt/jansson-2.7
39+
40+
RUN cd /opt && \
41+
git clone https://github.com/kaldi-asr/kaldi && \
42+
cd /opt/kaldi/tools && \
43+
make && \
44+
./install_portaudio.sh && \
45+
cd /opt/kaldi/src && ./configure --shared && \
46+
sed -i '/-g # -O0 -DKALDI_PARANOID/c\-O3 -DNDEBUG' kaldi.mk && \
47+
make depend && make && \
48+
cd /opt/kaldi/src/online && make depend && make && \
49+
cd /opt/kaldi/src/gst-plugin && make depend && make && \
50+
cd /opt && \
51+
git clone https://github.com/alumae/gst-kaldi-nnet2-online.git && \
52+
cd /opt/gst-kaldi-nnet2-online/src && \
53+
sed -i '/KALDI_ROOT?=\/home\/tanel\/tools\/kaldi-trunk/c\KALDI_ROOT?=\/opt\/kaldi' Makefile && \
54+
make depend && make && \
55+
rm -rf /opt/gst-kaldi-nnet2-online/.git/ && \
56+
find /opt/gst-kaldi-nnet2-online/src/ -type f -not -name '*.so' -delete && \
57+
rm -rf /opt/kaldi/.git && \
58+
rm -rf /opt/kaldi/egs/ /opt/kaldi/windows/ /opt/kaldi/misc/ && \
59+
find /opt/kaldi/src/ -type f -not -name '*.so' -delete && \
60+
find /opt/kaldi/tools/ -type f \( -not -name '*.so' -and -not -name '*.so*' \) -delete && \
61+
cd /opt && git clone https://github.com/alumae/kaldi-gstreamer-server.git && \
62+
rm -rf /opt/kaldi-gstreamer-server/.git/ && \
63+
rm -rf /opt/kaldi-gstreamer-server/test/
64+
65+
COPY start.sh stop.sh /opt/
66+
67+
RUN mkdir -p /opt/models && cd /opt/models && \
68+
wget https://phon.ioc.ee/~tanela/tedlium_nnet_ms_sp_online.tgz && \
69+
tar -zxvf tedlium_nnet_ms_sp_online.tgz && \
70+
wget https://raw.githubusercontent.com/alumae/kaldi-gstreamer-server/master/sample_english_nnet2.yaml -P /opt/models && \
71+
find /opt/models/ -type f | xargs sed -i 's:test:/opt:g' && \
72+
sed -i 's:full-post-processor:#full-post-processor:g' /opt/models/sample_english_nnet2.yaml
73+
74+
75+
76+
RUN chmod +x /opt/start.sh && \
77+
chmod +x /opt/stop.sh
78+
79+
CMD /opt/start.sh -y /opt/models/sample_english_nnet2.yaml
80+
81+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Working example with single docker file
2+
This docker file automates the process described in the practial end to end example.
3+
It is purely meant for creating a basic test system very quickly.
4+
It creates a single Docker Image and starts the Kaldi master and a single worker. It also downloads a model.
5+
Due to the size of the model it take take a while to create this docker image.
6+
7+
#Steps to run
8+
Build the docker image
9+
```
10+
docker build -t docker-kaldi-gstreamer-example:latest .
11+
```
12+
13+
Run the docker image
14+
```
15+
docker run -itd -p 8080:80 --shm-size=256m docker-kaldi-gstreamer-example:latest
16+
17+
```
18+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
MASTER="localhost"
4+
PORT=80
5+
6+
usage(){
7+
echo "Creates a worker and connects it to a master.";
8+
echo "If the master address is not given, a master will be created at localhost:80";
9+
echo "Usage: $0 -y yaml_file [-m master address] [-p port number]";
10+
}
11+
12+
while getopts "h?m:p:y:" opt; do
13+
case "$opt" in
14+
h|\?)
15+
usage
16+
exit 0
17+
;;
18+
m) MASTER=$OPTARG
19+
;;
20+
p) PORT=$OPTARG
21+
;;
22+
y) YAML=$OPTARG
23+
;;
24+
esac
25+
done
26+
27+
#yaml file must be specified
28+
if [ "$YAML" == "" ] ; then
29+
usage;
30+
exit 1;
31+
fi;
32+
33+
34+
if [ "$MASTER" == "localhost" ] ; then
35+
# start a local master
36+
python /opt/kaldi-gstreamer-server/kaldigstserver/master_server.py --port=$PORT 2>> /opt/master.log &
37+
fi
38+
39+
#start worker and connect it to the master
40+
export GST_PLUGIN_PATH=/opt/gst-kaldi-nnet2-online/src/:/opt/kaldi/src/gst-plugin/
41+
42+
python /opt/kaldi-gstreamer-server/kaldigstserver/worker.py -c $YAML -u ws://$MASTER:$PORT/worker/ws/speech 2>> /opt/worker.log

examples/practical-example/stop.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
#kill worker
4+
ps axf | grep worker.py | grep -v grep | awk '{print "kill -15 " $1}' | sh
5+
6+
#kill master
7+
ps axf | grep master_server.py | grep -v grep | awk '{print "kill -15 " $1}' | sh
8+

0 commit comments

Comments
 (0)