Skip to content

Commit 5e63a33

Browse files
authored
Merge pull request #7 from rdavidson/master
Dockerfile for end to end example.
2 parents cfb02e0 + 26c1ac8 commit 5e63a33

File tree

4 files changed

+157
-0
lines changed

4 files changed

+157
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
FROM debian:8
2+
MAINTAINER Eduardo Silva <[email protected]>
3+
4+
RUN apt-get update && apt-get install -y \
5+
autoconf \
6+
automake \
7+
bzip2 \
8+
g++ \
9+
git \
10+
gstreamer1.0-plugins-good \
11+
gstreamer1.0-tools \
12+
gstreamer1.0-pulseaudio \
13+
gstreamer1.0-plugins-bad \
14+
gstreamer1.0-plugins-base \
15+
gstreamer1.0-plugins-ugly \
16+
libatlas3-base \
17+
libgstreamer1.0-dev \
18+
libtool-bin \
19+
make \
20+
python2.7 \
21+
python-pip \
22+
python-yaml \
23+
python-simplejson \
24+
python-gi \
25+
subversion \
26+
wget \
27+
zlib1g-dev && \
28+
apt-get clean autoclean && \
29+
apt-get autoremove -y && \
30+
pip install ws4py==0.3.2 && \
31+
pip install tornado && \
32+
ln -s /usr/bin/python2.7 /usr/bin/python ; ln -s -f bash /bin/sh
33+
34+
RUN cd /opt && wget http://www.digip.org/jansson/releases/jansson-2.7.tar.bz2 && \
35+
bunzip2 -c jansson-2.7.tar.bz2 | tar xf - && \
36+
cd jansson-2.7 && \
37+
./configure && make && make check && make install && \
38+
echo "/usr/local/lib" >> /etc/ld.so.conf.d/jansson.conf && ldconfig && \
39+
rm /opt/jansson-2.7.tar.bz2 && rm -rf /opt/jansson-2.7
40+
41+
RUN cd /opt && \
42+
git clone https://github.com/kaldi-asr/kaldi && \
43+
cd /opt/kaldi/tools && \
44+
make && \
45+
./install_portaudio.sh && \
46+
cd /opt/kaldi/src && ./configure --shared && \
47+
sed -i '/-g # -O0 -DKALDI_PARANOID/c\-O3 -DNDEBUG' kaldi.mk && \
48+
make depend && make && \
49+
cd /opt/kaldi/src/online && make depend && make && \
50+
cd /opt/kaldi/src/gst-plugin && make depend && make && \
51+
cd /opt && \
52+
git clone https://github.com/alumae/gst-kaldi-nnet2-online.git && \
53+
cd /opt/gst-kaldi-nnet2-online/src && \
54+
sed -i '/KALDI_ROOT?=\/home\/tanel\/tools\/kaldi-trunk/c\KALDI_ROOT?=\/opt\/kaldi' Makefile && \
55+
make depend && make && \
56+
rm -rf /opt/gst-kaldi-nnet2-online/.git/ && \
57+
find /opt/gst-kaldi-nnet2-online/src/ -type f -not -name '*.so' -delete && \
58+
rm -rf /opt/kaldi/.git && \
59+
rm -rf /opt/kaldi/egs/ /opt/kaldi/windows/ /opt/kaldi/misc/ && \
60+
find /opt/kaldi/src/ -type f -not -name '*.so' -delete && \
61+
find /opt/kaldi/tools/ -type f \( -not -name '*.so' -and -not -name '*.so*' \) -delete && \
62+
cd /opt && git clone https://github.com/alumae/kaldi-gstreamer-server.git && \
63+
rm -rf /opt/kaldi-gstreamer-server/.git/ && \
64+
rm -rf /opt/kaldi-gstreamer-server/test/
65+
66+
COPY start.sh stop.sh /opt/
67+
68+
RUN mkdir -p /opt/models && cd /opt/models && \
69+
wget https://phon.ioc.ee/~tanela/tedlium_nnet_ms_sp_online.tgz && \
70+
tar -zxvf tedlium_nnet_ms_sp_online.tgz && \
71+
wget https://raw.githubusercontent.com/alumae/kaldi-gstreamer-server/master/sample_english_nnet2.yaml -P /opt/models && \
72+
find /opt/models/ -type f | xargs sed -i 's:test:/opt:g' && \
73+
sed -i 's:full-post-processor:#full-post-processor:g' /opt/models/sample_english_nnet2.yaml
74+
75+
76+
77+
RUN chmod +x /opt/start.sh && \
78+
chmod +x /opt/stop.sh
79+
80+
CMD /opt/start.sh -y /opt/models/sample_english_nnet2.yaml
81+
82+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 may take a while to build 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+
19+
## Test the install
20+
On your host machine, download a client example and test your setup with a given audio:
21+
```
22+
wget https://raw.githubusercontent.com/alumae/kaldi-gstreamer-server/master/kaldigstserver/client.py -P /tmp
23+
wget https://raw.githubusercontent.com/alumae/kaldi-gstreamer-server/master/test/data/bill_gates-TED.mp3 -P /tmp
24+
python /tmp/client.py -u ws://localhost:8080/client/ws/speech -r 8192 /tmp/bill_gates-TED.mp3
25+
```
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)