/
jasper-installer.sh
executable file
·254 lines (209 loc) · 8.74 KB
/
jasper-installer.sh
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#!/bin/sh
## jasper-installer.sh - Script designed to install jasper on raspbian.
## Copyright (C) 2016 Richard Nelson <unixabg@gmail.com>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
set -e
#set -x
Defaults () {
# Function for Defaults
echo "$(date) - Called Defaults..." >> ~/jasper-installer.log
echo "$(date) - Start jasper-installer script." >> ~/jasper-installer.log
echo "$(date) - Update raspbian..." >> ~/jasper-installer.log
# Update raspbian
sudo apt-get update
sudo apt-get upgrade --yes
echo "$(date) - Append PATH var and export LD_LIBRARY_PATH..." >> ~/jasper-installer.log
# Append PATH var and export LD_LIBRARY_PATH
cat <<EOT >> /home/pi/.bashrc
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
PATH=$PATH:/usr/local/lib/
export PATH
EOT
}
JasperBase () {
# Function to install Jasper base
echo "$(date) - Called JasperBase..." >> ~/jasper-installer.log
echo "$(date) - Checkout Jasper from git..." >> ~/jasper-installer.log
# Checkout Jasper from git
git clone https://github.com/jasperproject/jasper-client.git jasper
echo "$(date) - Install Jasper requirements..." >> ~/jasper-installer.log
# Install Jasper requirements
# First upgrade pip
sudo easy_install pip
# Now begin
cd ~
sudo pip install --upgrade setuptools
sudo pip install -r ~/jasper/client/requirements.txt
chmod +x jasper/jasper.py
echo "$(date) - Adding support for Google STT..." >> ~/jasper-installer.log
# Adding support for Google STT
sudo apt-get install python-pymad --yes
sudo pip install --upgrade gTTS
}
JasperLocal () {
# Function to install Jasper local
echo "$(date) - Called JasperLocal..." >> ~/jasper-installer.log
echo "$(date) - Install the dependencies for Jasper local..." >> ~/jasper-installer.log
echo "$(date) - Download and extract packages for STT..." >> ~/jasper-installer.log
# Download and extract packages for STT
# The Pocketsphinx STT engine requires the MIT Language Modeling Toolkit,
# m2m-aligner, Phonetisaurus
cd ~
wget http://downloads.sourceforge.net/project/cmusphinx/sphinxbase/0.8/sphinxbase-0.8.tar.gz
wget http://downloads.sourceforge.net/project/cmusphinx/pocketsphinx/0.8/pocketsphinx-0.8.tar.gz
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/mitlm/mitlm-0.4.1.tar.gz
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/m2m-aligner/m2m-aligner-1.2.tar.gz
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/phonetisaurus/is2013-conversion.tgz
wget https://www.dropbox.com/s/kfht75czdwucni1/g014b2b.tgz
svn co https://svn.code.sf.net/p/cmusphinx/code/trunk/cmuclmtk/
tar xvf sphinxbase-0.8.tar.gz
tar xvf pocketsphinx-0.8.tar.gz
tar xvf m2m-aligner-1.2.tar.gz
tar xvf is2013-conversion.tgz
tar xvf mitlm-0.4.1.tar.gz
tar xvf g014b2b.tgz
# Install Speech-To-Text Engine Pocketsphinx and CMUCLMTK
echo "$(date) - Building sphinxbase-0.8..." >> ~/jasper-installer.log
cd ~/sphinxbase-0.8/
./configure --enable-fixed
make -j2
sudo make install
echo "$(date) - Completed building and installing sphinxbase-0.8..." >> ~/jasper-installer.log
echo "$(date) - Building pocketshinx-0.8..." >> ~/jasper-installer.log
cd ~/pocketsphinx-0.8/
./configure
make -j2
sudo make install
echo "$(date) - Completed building and installing pocketshinx-0.8..." >> ~/jasper-installer.log
echo "$(date) - Building cmuclmtk..." >> ~/jasper-installer.log
cd ~/cmuclmtk/
./autogen.sh
make -j2
sudo make install
echo "$(date) - Completed building and installing cmuclmtk..." >> ~/jasper-installer.log
# Install M2M, MITLMT, Phonetisaurus and Phonetisaurus FST
echo "$(date) - Building m2m-aligner-1.2..." >> ~/jasper-installer.log
cd ~/m2m-aligner-1.2/
make -j2
sudo cp ~/m2m-aligner-1.2/m2m-aligner /usr/local/bin/m2m-aligner
echo "$(date) - Completed building and installing m2m-aligner-1.2..." >> ~/jasper-installer.log
echo "$(date) - Building mitlm-0.4.1..." >> ~/jasper-installer.log
cd ~/mitlm-0.4.1/
./configure
make -j2
sudo make install
echo "$(date) - Completed building and installing mitlm-0.4.1..." >> ~/jasper-installer.log
echo "$(date) - Building is2013-conversion..." >> ~/jasper-installer.log
cd ~/is2013-conversion/phonetisaurus/src/
make -j2
sudo cp ~/is2013-conversion/bin/phonetisaurus-g2p /usr/local/bin/phonetisaurus-g2p
echo "$(date) - Completed building and installing is2013-conversion..." >> ~/jasper-installer.log
echo "$(date) - Building g014b2b..." >> ~/jasper-installer.log
echo "$(date) - Export the LD_LIBRARY_PATH for fstcompiler..." >> ~/jasper-installer.log
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
cd ~/g014b2b/
./compile-fst.sh
cd
mv ~/g014b2b ~/phonetisaurus
echo "$(date) - Completed building and installing g014b2b..." >> ~/jasper-installer.log
}
JasperTools () {
# Function to install Jasper tools
echo "$(date) - Called JasperTools..." >> ~/jasper-installer.log
echo "$(date) - Install the dependencies and some other packages..." >> ~/jasper-installer.log
# Install the dependencies and some other packages
sudo apt-get install vim git-core python-dev python-pip bison libasound2-dev libportaudio-dev python-pyaudio espeak subversion autoconf libtool automake gfortran g++ libfst-dev libfst-tools libfst1 --yes
}
JasperTweaks () {
## Modify the CHUNK in jasper/client/mic.py
#sed -i.bak -e's/1024/768/' ~/jasper/client/mic.py
echo "$(date) - Modify the default sound card in jasper/client/tts.py..." >> ~/jasper-installer.log
# Modify the default sound card in jasper/client/tts.py
sed -i.bak -e's/plughw:1,0/plughw:0,0/' ~/jasper/client/tts.py
echo "$(date) - Adjust the sound card defalut in alsa.conf..." >> ~/jasper-installer.log
# Adjust the sound card defalut in alsa.conf
#sudo sed -i.bak -e's/defaults.ctl.card 0/defaults.ctl.card 1/' /usr/share/alsa/alsa.conf
sudo sed -i.bak -e's/defaults.pcm.card 0/defaults.pcm.card 1/' /usr/share/alsa/alsa.conf
#echo "$(date) - Install crontab FIXME..." >> ~/jasper-installer.log
## Install crontab
#(crontab -u pi -l; echo '@reboot /home/pi/jasper/jasper.py') | sudo crontab -u pi -
}
JasperVoice () {
# Function to install female voice for Jasper
echo "$(date) - Called JasperVoice..." >> ~/jasper-installer.log
echo "$(date) - Install svox tools for female voice..." >> ~/jasper-installer.log
sudo apt-get install libttspico-data libttspico-utils libttspico0 --yes
}
_STT="NETWORK"
cat << EOF
######################################################
Welcome to the jasper-installer.sh script.
######################################################
######################################################
The installer script can install Jasper with or
without local Speech To Text (STT) support. By default
the jasper-installer.sh script will assume you want
network based STT. If you want local STT please answer
the question accordingly.
Select the desired STT support of (NETWORK or LOCAL)
(default: ${_STT})
EOF
# Ask for _STT
echo -n ": "
read _READ
_STT=${_READ:-${_STT}}
_SVOX="FEMALE"
cat << EOF
######################################################
The installer script can install Jasper with a female
voice for Text To Speech (TTS) support. By default the
jasper-installer.sh script will assume you want a
femal voice. If you want the regular Jasper male voice
please answer the question accordingly.
Select the desired voice for TTS support of (FEMALE or MALE)
(default: ${_SVOX})
EOF
# Ask for _SVOX
echo -n ": "
read _READ
_SVOX=${_READ:-${_SVOX}}
Defaults
JasperTools
JasperBase
# Here we include the building of STT tools local
if [ "${_STT}" = "LOCAL" ]
then
echo "$(date) - User selected LOCAL STT option..." >> ~/jasper-installer.log
JasperLocal
else
echo "$(date) - User selected NETWORK STT option..." >> ~/jasper-installer.log
fi
# Here we include the voice for TTS
if [ "${_SVOX}" = "MALE" ]
then
echo "$(date) - User selected MALE TTS voice..." >> ~/jasper-installer.log
else
# Here we default to FEMALE for everything else entered.
echo "$(date) - User selected FEMALE TTS voice..." >> ~/jasper-installer.log
JasperVoice
fi
JasperTweaks
echo "$(date) - Jasper install attempt completed..." >> ~/jasper-installer.log
echo "$(date) - Jasper install attempt completed."
echo "$(date) - Please remember to run the following to configure Jasper:"
echo
echo 'python ~/jasper/client/populate.py'
echo
echo 'Also please reboot your computer once for good measure.'
echo 'Thanks for trying jasper-installer.sh script.'
#echo "$(date) - Populate the ~/.jasper/FIXME..." >> ~/jasper-installer.log
## Populate the ~/.jasper/FIXME
#cd ~/jasper/client
#python populate.py
#echo "$(date) - Reboot for jasper launch..." >> ~/jasper-installer.log
## Reboot for jasper launch
#sudo reboot
exit 0