-
Notifications
You must be signed in to change notification settings - Fork 4
/
requirements
executable file
·307 lines (274 loc) · 8.95 KB
/
requirements
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#!/bin/bash
#
# The install script for Dexter's requirements.
#
# This won't install everything by default, it will look to pick the best things
# it can but you can configure it by invoking it with different options.
usage() {
echo "Install the requirements for Dexter"
echo
echo "By default the script will attempt to do what's right for your system"
echo "but you can use the options to change that behaviour."
echo
echo "It should be safe to run this script multiple times, but some "
echo "dependencies may clash with others."
echo
echo "Usage:"
echo " `basename $0` [options]"
echo " --whisper-stt Install the Whisper speech-to-text engine"
echo " --vosk-stt Install the Vosk speech-to-text engine"
echo " --coqui-stt Install the Coqui speech-to-text engine"
echo " --mimic3-tts Install the Mimic3 text-to-speech engine"
echo " --coqui-tts Install the Coqui text-to-speech engine"
echo " --festival-tts Install the Festival text-to-speech engine"
echo " --upnp Install UPnP dependencies, including VLC"
}
# Cheesy getopt implementation follows. Please don't judge me.
for arg in $@
do
case $arg in
--whisper-stt) INSTALL_WHISPER_STT=true;;
--vosk-stt) INSTALL_VOSK_STT=true;;
--coqui-stt) INSTALL_COQUI_STT=true;;
--mimic3-tts) INSTALL_MIMIC3_TTS=true;;
--coqui-tts) INSTALL_COQUI_TTS=true;;
--festival-tts) INSTALL_FESTIVAL_TTS=true;;
--upnp) INSTALL_UPNP=true;;
*) usage ; exit 1 ;;
esac
done
# ----------------------------------------------------------------------------
# Let the user have some time to realise what we're doing.
echo
echo " *** WARNING ***"
echo
echo " This will install A LOT of things on your system"
echo
echo " If you don't want to do this then hit CTRL-C now"
echo
echo " *** WARNING ***"
echo
echo -n "Installing in "
for i in 10 9 8 7 6 5 4 3 2 1
do
echo -n "$i "
sleep 1
done
echo '.'
# ----------------------------------------------------------------------------
# We'll need to know some things about our environment for some of the below.
if uname -m | grep -q aarch64
then
AARCH64=true
else
AARCH64=false
fi
if uname -m | grep -q 'x86_64'
then
X86_64=true
else
X86_64=false
fi
# Where we are invoked from
ROOT=`dirname $0`
# ----------------------------------------------------------------------------
# Now install what you will need to make all of this work. Some things are not
# required, depending on whether you don't care about certain modules. On
# Raspberry Pi OS and Ubuntu the following should mostly work. If you see errors
# then it might be fine depending on what platform you're on.
# Things which we expect to have in both OSes.
echo
echo "Running apt update"
sudo apt update
echo
echo "Installing common requirements"
sudo apt install -y \
git swig portaudio19-dev \
python3-pip python3-numpy python3-scipy python3-argh python3-pyalsa \
python3-espeak python3-fuzzywuzzy python3-httplib2 python3-mutagen python3-pygame \
python3-kivy libpulse-dev libasound2-dev python3-virtualenv
# Activate the virtualenv
VENV=${ROOT}/venv
test -d $VENV/. || {
echo
echo "Creating virtualenv in $VENV"
echo
virtualenv $VENV || exit 1
}
echo
echo "Activating virtualenv $VENV"
. ${VENV}/bin/activate || exit 1
echo
# Required.
echo "Installing common Python requirements"
pip install pyaudio
pip install pyjson5
pip install pyalsaaudio
pip install argh
pip install fuzzywuzzy
pip install python-Levenshtein
pip install httplib2
pip install mutagen
pip install pygame
pip install kivy
# You _probably_ want these so we optimistically install them. And, at the end
# of the day, they are light so it doesn't hurt.
echo
echo "Installing service Python requirements"
pip install wikipedia
pip install spotipy
pip install PyDictionary
pip install python-kasa
pip install blink1
pip install blinkstick pyusb
# Ubuntu has this, Raspbian does not, so try both locations.
sudo apt install -y python3-levenshtein || pip install python-Levenshtein
# Optionally install VLC since, including its dependencies, since there's a lot
# of it. We currently only need it for the UPnP stuff.
if ${INSTALL_UPNP:-false}
then
echo
echo "Installing VLC and UPnP libraries"
sudo apt install -y python3-vlc
pip install python-vlc
pip install python-didl-lite
pip install git+https://github.com/iamsrp/upnpy
fi
# ----------------------------------------------------------------------------
# Now the Speech-to-Text and Text-to-Speech engines. We only try to install one
# of these since they can conflict with one another and you should only need one
# of each anyhow.
# Speech-to-Text.
# Look for Whisper first, that's the best one but requires a fast CPU (or a
# GPU). This will currently clash with Coqui so don't install it if that's been
# selected.
if $X86_64
then
if ${INSTALL_COQUI_STT:-false}
then
: ${INSTALL_WHISPER_STT:=false}
else
: ${INSTALL_WHISPER_STT:=true}
fi
else
: ${INSTALL_WHISPER_STT:=false}
fi
# Vosk is another decent STT engine. This mostly only works for Ubuntu and 64bit
# Raspbian that I can tell.
if $INSTALL_WHISPER_STT
then
: ${INSTALL_VOSK_STT:=false}
elif $AARCH64 || $X86_64
then
: ${INSTALL_VOSK_STT:=true}
else
: ${INSTALL_VOSK_STT:=false}
fi
# If we aren't installing Whisper then Coqui is a good alternative.
if $INSTALL_WHISPER_STT || $INSTALL_VOSK_STT
then
: ${INSTALL_COQUI_STT:=false}
else
: ${INSTALL_COQUI_STT:=true}
fi
# Text-to-Speech.
# Mycroft is the best sounding TTS IMHO so prefer that one first. You can
# install it on 32bit Raspbian bit it requires human intervention so we don't
# try that here.
if $AARCH64 || $X86_64
then
: ${INSTALL_MIMIC3_TTS:=true}
else
: ${INSTALL_MIMIC3_TTS:=false}
fi
# And the Coqui STT, which was DeepSpeech once upon a time, is a good fallback
# but has Numpy versioning issues and depends on PyTorch (and about a million
# other things too). So we only install for Ubuntu x86_64 by default.
if $INSTALL_MIMIC3_TTS
then
: ${INSTALL_COQUI_TTS:=false}
elif $X86_64
then
: ${INSTALL_COQUI_TTS:=true}
else
: ${INSTALL_COQUI_TTS:=false}
fi
# If none of those are being installed then Festival is a fine fallback.
if $INSTALL_COQUI_TTS || $INSTALL_MIMIC3_TTS
then
: ${INSTALL_FESTIVAL_TTS:=false}
else
: ${INSTALL_FESTIVAL_TTS:=true}
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Now the actual installs...
if $INSTALL_WHISPER_STT
then
# Whisper only works on the 64bit Pi OS since it needs PyTorch, which is
# 64bit only. (PyTorch looks to need a more up-to-date numpy than is
# currently available via apt.) We only install ffmpeg and upgrade numpy if
# it succeeds.
echo
echo "Installing Whisper and ffmpeg"
pip install git+https://github.com/openai/whisper.git &&
sudo apt install -y ffmpeg &&
pip install -U numpy
fi
if $INSTALL_VOSK_STT
then
# See https://github.com/alphacep/vosk-api/releases/
echo
echo "Installing Vosk"
pip install vosk ||
pip install https://github.com/alphacep/vosk-api/releases/download/v0.3.45/vosk-0.3.45-py3-none-linux_`uname -m`.whl
fi
if $INSTALL_COQUI_STT
then
# See https://github.com/coqui-ai/STT/releases/
echo
echo "Installing Coqui STT"
pip install stt ||
pip install https://github.com/coqui-ai/STT/releases/download/v1.4.0/stt-1.4.0-cp39-cp39-linux_`uname -m`.whl
fi
if $INSTALL_MIMIC3_TTS
then
# Mycroft works for 64bit archs. Installing it for 32bit Raspbian is a little
# more involved (see the module).
echo
echo "Installing Mycroft Mimic3 TTS"
pip install mycroft-mimic3-tts
fi
if $INSTALL_COQUI_TTS
then
echo
echo "Installing Coqui TTS"
pip install TTS
fi
if $INSTALL_FESTIVAL_TTS
then
sudo apt install -y festival festival-dev festvox-us-slt-hts
pip install git+https://github.com/techiaith/pyfestival#festival
fi
# ----------------------------------------------------------------------------
# Ensure that the user can access any audio devices. This is needed for Dexter
# to hear things and say things.
aplay -l |& grep -q 'no soundcards found' && {
groups | grep -q audio || {
sudo adduser $USER audio
echo
echo "WARNING *********************************************************"
echo "WARNING ** Added $USER to the audio group **"
echo "WARNING ** you may need to log back into to pick up the change **"
echo "WARNING *********************************************************"
}
}
# ----------------------------------------------------------------------------
# And we're done!
echo
echo "Python compoments install into $VENV. Use"
echo " . $VENV/bin/activate"
echo "to enable it before running dexter."
echo
echo " Installation complete!"
echo
exit 0