-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall
More file actions
executable file
·237 lines (208 loc) · 7.79 KB
/
Copy pathinstall
File metadata and controls
executable file
·237 lines (208 loc) · 7.79 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#!/bin/bash
#Installation
# All of these commands are run from the base folder (SunFounder_PiSmart), wherever you clone it to
if [ "$(whoami)" != "root" ] ; then
echo -e "You must run as root. Try:\n sudo ./install"
exit
fi
install_dir=`pwd`
dependences_dir=$install_dir"/dependencies"
sudo apt-get update
###################################
# installation summary #
###################################
summary="\n
Summary:\n
"
dep_install(){
echo "Installinging $2"
if sudo $1 install $2 -y; then
echo -e "Successfully installed $2\n"
summary=$summary"\n $2 Success"
return 1
else
echo -e "Failed to installed $2\n"
summary=$summary"\n $2 Fail"
return 0
fi
}
apt_install(){
dep_install "apt-get" $1
return $?
}
pip_install(){
dep_install "pip" $1
return $?
}
###################################
# apt install espeak festival pico runtime #
###################################
apt_install "espeak"
apt_install "festival"
apt_install "libttspico-utils"
###################################
# apt install pocketsphinx i2c-tools python-smbus runtime #
###################################
apt_install "pocketsphinx"
apt_install "i2c-tools"
apt_install "python-smbus"
####################
# apt install GStreamer#
####################
# Install GStreamer using:
apt_install "python-gst0.10"
apt_install "gstreamer-0.10"
apt_install "gstreamer0.10-plugins-good"
apt_install "gstreamer0.10-plugins-ugly"
apt_install "gstreamer1.0-pocketsphinx"
if [[ "$?" == "0" ]]; then
apt_install "gstreamer0.10-pocketsphinx"
fi
apt_install "bison"
# Needed for make
apt_install "make"
apt_install "python-dev"
apt_install "swig"
# Install pocketsphinx for Python
apt_install "python-pocketsphinx"
if [[ "$?" == "0" ]]; then
apt_install "python-pip"
pip_install "pocketsphinx"
fi
cd $dependences_dir
#######################################
# tar install antlr3.4 python runtime #
#######################################
ls /usr/local/lib/python2.7/dist-packages/antlr_python_runtime-3.4-py2.7.egg/antlr3 > /dev/null
if [[ "$?" == "0" ]]; then
echo "You have installed antlr3.4 before, skip."
summary=$summary"\n antlr3.4 skip"
else
if tar -xf antlr-3.4.tar.gz && \
cd antlr-3.4/runtime/Python && \
sudo python setup.py install; then
echo "Successfully installed antlr3.4 runtime."
summary=$summary"\n antlr3.4 Success"
else
echo "Failed to install antlr3.4 runtime."
summary=$summary"\n antlr3.4 Fail"
fi
cd $dependences_dir # cd to dependencies dir
fi
#NOTE: You can stop here if you don't care about speech recognition support and just desire usage of the text-based capabilities of SpeakPython
######################
# tar install sphinxbase #
######################
ls /usr/local/lib/python2.7/dist-packages/sphinxbase > /dev/null
if [[ "$?" == "0" ]]; then
echo "You have installed sphinxbase before, skip."
summary=$summary"\n sphinxbase skip"
else
if tar -xf sphinxbase-5prealpha.tar.gz && \
cd sphinxbase-5prealpha && \
./configure && \
make clean && \
make && \
sudo make install ; then
echo "Successfully installed sphinxbase."
summary=$summary"\n sphinxbase Success"
else
echo "Failed to install sphinxbase."
summary=$summary"\n sphinxbase Fail"
fi
cd $dependences_dir # cd to dependencies dir
fi
########################
# tar install pocketsphinx #
########################
ls /usr/local/lib/pkgconfig/pocketsphinx.pc > /dev/null
if [[ "$?" == "0" ]]; then
echo "You have installed pocketsphinx before, skip."
summary=$summary"\n pocketsphinx Skip"
else
if tar -xf pocketsphinx-5prealpha.tar.gz && \
cd pocketsphinx-5prealpha && \
./configure && \
make clean && \
make && \
sudo make install ; then
echo "Successfully installed pocketsphinx."
summary=$summary"\n pocketsphinx Success"
else
echo "Failed to install pocketsphinx."
summary=$summary"\n pocketsphinx Fail"
fi
cd $dependences_dir # cd to dependencies dir
fi
# Configure shared library paths
echo 'Exporting library paths...'
export LD_LIBRARY_PATH=/usr/local/lib
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export GST_PLUGIN_PATH=/usr/local/lib/gstreamer-0.10
# Make sure there's a pocketsphinx configuration (should output a folder called 'model')
# ls /usr/share/pocketsphinx/
# If this folder exists, we can replace it with the command below
#this will replace the existing model with one trained with suitable data for our application
# wsj1 is by default the ptm version of cmu-us-en-5.2, utilize untar and use the non-ptm version for slower, more resource-intensive, and accurate recognition
if tar -xf wsj1.tar.gz && \
sudo cp -r wsj1 /usr/share/pocketsphinx/model/hmm/ ; then
echo "Successfully copied pocketsphinx model."
else
echo "Failed to copy pocketsphinx model."
fi
#```
########################
# tar install g2p #
########################
#Install g2p.py for word to phoneme conversion (optional)
ls /usr/local/lib/python2.7/dist-packages/g2p.py > /dev/null
if [[ "$?" == "0" ]]; then
echo "You have installed Sequitur-g2p before, skip."
summary=$summary"\n Sequitur-g2p Skip"
else
if tar -xf Sequitur-g2p.tar.gz && \
cd Sequitur-g2p/g2p && \
sudo python setup.py install --prefix /usr/local ; then
echo "Successfully installed Sequitur-g2p (g2p.py)"
summary=$summary"\n Sequitur-g2p Success"
else
echo "Failed to install Sequitur-g2p (g2p.py)"
summary=$summary"\n Sequitur-g2p Fail"
fi
cd $dependences_dir # cd to dependencies dir
echo 'Cleaning up...'
sudo rm -rf antlr-3.4 wsj1 Sequitur-g2p sphinxbase-5prealpha pocketsphinx-5prealpha
echo 'done'
fi
#speakpython dictionary
echo 'Copying files...'
cd $install_dir
sudo cp ./bin/* /usr/local/bin
sudo cp -r ./data/* /usr/local/bin
sudo cp /usr/local/lib/libsphinxbase.so.3 /usr/lib
echo 'done'
# Install PiSmart:
echo 'Install PiSmart'
sudo python setup.py install
#######################
# Enable I2C1 SPI#
#######################
# Add lines to /boot/config.txt
echo -e "Enalbe I2C \n"
egrep -v "^#|^$" /boot/config.txt > config.txt.temp # pick up all uncomment configrations
if grep -q 'dtparam=i2c_arm=on' config.txt.temp; then # whether i2c_arm in uncomment configrations or not
echo -e ' Seem i2c_arm parameter already set, skip this step \n'
else
echo -e ' dtparam=i2c_arm=on \n' >> /boot/config.txt
fi
if grep -q 'dtparam=spi=on' config.txt.temp; then # whether SPI in uncomment configrations or not
echo -e ' Seem spi parameter already set, skip this step \n'
else
echo -e ' dtparam=spi=on \n' >> /boot/config.txt
fi
rm config.txt.temp
echo -e "i2c & spi enable\n"
##############################
# print installation summary #
##############################
echo -e $summary