-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconfigure
executable file
·170 lines (136 loc) · 5.71 KB
/
configure
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/env bash
#
# Copyright 2016 Thomas Schatz, Xuan-Nga Cao, Mathieu Bernard
#
# This file is part of abkhazia: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Abkhazia is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with abkahzia. If not, see <http://www.gnu.org/licenses/>.
# This script configures abkhazia before installation. It checks if
# dependancies are installed (kaldi, sox, shorten and CMU dict) and
# setup the path to kaldi. It also creates the following files in
# ./abkhazia/share
#
# - abkhazia.conf default configuration file
# - path.sh and cmd.sh used by kaldi recipes
#
# Until all is correctly configured, the script fails with an error
# message advising you how to fix the issue. Fix it and rerun the
# script until it succeed.
# equivalent to $(readlink -f $1) but in pure bash (compatible with
# mac OS)
function realpath {
pushd `dirname $1` > /dev/null
echo $(pwd -P)
popd > /dev/null
}
# called when a configuration error occurs
function failure {
echo "Configuration failed !
$1
Please fix the problem and run this script again";
exit 1;
}
# absolute path to the abkhazia setup directory
setupdir=$(realpath $0)
# path to the share directory in abkhazia
share=$setupdir/abkhazia/share
# download the CMU pronouncing dictionary if not present
cmu_url="http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict.0.7a"
cmu_dic=$share/`basename $cmu_url`
if [ -e $cmu_dic ]
then
echo "Found CMU dictionary as $cmu_dic"
else
echo "Downloading CMU dictionary from $cmu_url..."
wget --quiet $cmu_url -O $cmu_dic || failure "Fail to download $cmu_url"
fi
# check sox is installed
sox=`which sox`
sox_failure="sox not found on your system, please install it (see http://sox.sourceforge.net)"
[ ! -z $sox ] && echo "Found sox as $sox" || failure "$sox_failure"
# check shorten is installed
shorten=`which shorten`
shorten_failure="shorten not found on your system, please install it from
http://shnutils.freeshell.org/shorten/dist/src/shorten-3.6.1.tar.gz"
[ ! -z $shorten ] && echo "Found shorten as $shorten" || failure "$shorten_failure"
# check festival is installed
festival=`which festival`
festival_failure="festival not found on your system, please install it
(see http://www.cstr.ed.ac.uk/projects/festival)"
[ ! -z $festival ] && echo "Found festival as $festival" || failure "$festival_failure"
# configuring abkhazia.conf
conf_in=$share/abkhazia.conf.in
conf=$share/abkhazia.conf
if [ ! -e $conf ]; then
# Init an empty configuration file if not existing
echo "Writing $conf"
cp $conf_in $conf
else
echo "Found configuration file as $conf"
# check all sections defined in abkhazia.conf.in are in abkhazia.conf
sec_in=$(sed '/^#/d' $conf_in | grep -e '\[.*\]' | tr -d '[]' | sort)
sec_out=$(sed '/^#/d' $conf | grep -e '\[.*\]' | tr -d '[]' | sort)
[ ! "$sec_in" == "$sec_out" ] && failure "Some configuration sections are missing in $conf, please merge it from $conf_in"
# check all parameters defined in abkhazia.conf.in are in abkhazia.conf
sec_in=$(sed '/^#/d' $conf_in | grep -e '^.*:' | cut -d':' -f 1 | sort)
sec_out=$(sed '/^#/d' $conf | grep -e '^.*:' | cut -d':' -f 1 | sort)
[ ! "$sec_in" == "$sec_out" ] && failure "Some configuration parameters are missing in $conf, please merge it from $conf_in"
fi
# check if kaldi-directory is defined in the config file
kaldi=$(sed '/^#/d' $conf | grep kaldi-directory | cut -d: -f2 | sed 's/^ *//')
if [ -z $kaldi ]; then
# kaldi not defined, take it from the KALDI_PATH variable
[ -z $KALDI_PATH ] &&
failure "Please set KALDI_PATH to the Kaldi root directory (Kaldi must be compiled)
Use for exemple: 'KALDI_PATH=/path/to/kaldi ./configure'"
[ ! -d $KALDI_PATH ] &&
failure "KALDI_PATH must be a directory"
# get the absolute path
KALDI_PATH=$(cd $KALDI_PATH; pwd -P)
sed -i "s|kaldi-directory:$|kaldi-directory: $KALDI_PATH|" $conf || exit
kaldi=$KALDI_PATH
fi
# check kaldi-directory is an existing directory
[ -d $kaldi ] && echo "Found kaldi root directory as $kaldi" ||
failure "Please correct the path to the kaldi root directory in
KALDI_PATH,
$kaldi is not an existing directory"
# check sph2pipe is found in kaldi (also means kaldi is compiled)
sph2pipe="$kaldi/tools/sph2pipe_v2.5/sph2pipe"
[ -e $sph2pipe ] && echo "Found sph2pipe as $sph2pipe" ||
failure "$sph2pipe not found in the kaldi distribution"
# check irstlm is installed
irstlm=$kaldi/tools/irstlm
[ -d $irstlm ] && echo "Found irstlm root directory as $irstlm" ||
failure "Please install irstlm in kaldi tools:
cd $kaldi/tools
./extras/install_irstlm.sh
Please do not source the tools/env.sh as indicated by that
script, this is already done for you."
# check srilm is installed
srilm=$kaldi/tools/srilm
[ -d $srilm ] && echo "Found srilm root directory as $srilm" ||
failure "Please install srilm in kaldi tools:
cd $kaldi/tools
./extras/install_srilm.sh
Please do not source the tools/env.sh as indicated by that
script, this is already done for you."
# configure and copy path.sh
sed "s|^KALDI_ROOT=|KALDI_ROOT=$kaldi|" $share/path.sh.in > $share/path.sh
echo "Configured $share/path.sh"
# all is good !!
echo "
Configuration succeed ! To continue installation please type:
python setup.py build
python setup.py install
"
exit 0