Skip to content

Instantly share code, notes, and snippets.

@Adirockzz95
Created September 2, 2016 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Adirockzz95/7fcd0d440cfcc34cc3ff169c8353f9c6 to your computer and use it in GitHub Desktop.
Save Adirockzz95/7fcd0d440cfcc34cc3ff169c8353f9c6 to your computer and use it in GitHub Desktop.
#!/bin/bash
#Download all files in the HOME directory
CURR_DIR=$HOME
RPI_DEP=$HOME/RPI-Jasper-Dependencies
#Add path into PYTHONPATH variable
export PYTHONPATH=$PYTHONPATH:/$HOME/.local
#Change location for pip --user flag
export PYTHONUSERBASE=$HOME/.local
#Download all the dependencies
function download_deps() {
echo "INFO: Gathering all dependencies"
#precompiled .deb files
git clone https://github.com/mattcurrycom/RPI-Jasper-Dependencies.git
#pymad is required (for jasper-dev)
git clone https://github.com/jaqx0r/pymad.git
#clone jasper-dev branch
git clone -b jasper-dev https://github.com/jasperproject/jasper-client.git
# download phonetisaurus-g2p executable
wget https://www.dropbox.com/s/evz4lcuw534q6su/phonetisaurus-g2p
echo "INFO: Downloading successful, moving to intall pocketsphinx dependencies"
}
function install_pocketsphinx_deps(){
cd $RPI_DEP
echo "INFO: Installing .deb files"
#install pre-compiled pkgs
sudo dpkg -i *.deb
echo "INFO: Extracting g014b2b fst file"
#extract phonetisaurus and compile
tar -xvf phonetisaurus.tgz
cd $RPI_DEP/g014b2b/
echo "INFO: compiling fst model"
#reload sharing library cache
sudo ldconfig
sleep 1
#compile fst model
sudo sh ./compile-fst.sh
echo "INFO: compiling done"
cd $HOME
# move phonetisaurus executable PATH
sudo chmod +x $HOME/phonetisaurus-g2p
sudo mv $HOME/phonetisaurus-g2p /usr/local/sbin/
echo "INFO: Done with pocketsphinx dependencies"
echo "INFO: moving to install jasper dependencies"
}
function install_jasper_main() {
cd $HOME/jasper-client/
python setup.py install --user
echo "Installation successful."
}
function install_jasper_deps() {
#Install all required libraries
sudo apt-get install python-dev libyaml-dev libmad0-dev portaudio19-dev espeak --yes
sleep 1
#install python packages
pip install --user pyaudio
pip install --user feedparser
pip install --user cmuclmtk
pip install --user setuptools==26.1.1
cd $HOME/pymad
#compile pymad and install
sudo python config_unix.py
python setup.py install --user
echo "INFO: Done with jasper-dependencies"
echo "INFO: Moving to install Jasper package itself"
}
function set_profile() {
echo "INFO: creating profile.yml"
PROFILE=$HOME/.jasper/profile.yml
mkdir $HOME/.jasper/
cat > $PROFILE << EOP
first_name: Tony
last_name: Stark
carrier: ''
phone_number: ''
prefers_email: false
audio_engine: pyaudio
audio:
input_samplerate: 44100
input_chunksize: 4096
input_device: 'usb-pnp-sound-device'
output_device: 'usb-pnp-sound-device'
tts_engine: espeak-tts
stt_engine: sphinx
pocketsphinx:
fst_model: '${HOME}/RPI-Jasper-Dependencies/g014b2b/g014b2b.fst'
EOP
}
main() {
echo "***************************************************************************************
*Please take backup of your current image.*
*If you are running this script on Pi, instead consider using Mattcurry's pre-built image.
*Script installs minimum packages required to run Jasper-dev.
*By default, it uses pocketsphinx for STT and espeak TTS.
*By default, all the python pkgs are installed in $HOME/.local/
*If you get error :'module not found' then add above path in PYTHONPATH variable
*By default, usb-sound-card will be used for both input and output.
*If you don't hear any sound, then try editing your alsa.conf file. (see jasper forum)
*Tested on : C.H.I.P, Pi-2 (Jessie).
**********************************************************************************************"
echo "Do you want to continue?[yes/no]:"
read ANS
if [[ $ANS == "yes" ]]; then
if [[ $HOME == $PWD ]]; then
download_deps
install_pocketsphinx_deps
install_jasper_deps
install_jasper_main
set_profile
else
echo "place this file in your home directory"
exit 1
fi
else
echo "Installation cancelled"
exit 0
fi
}
main
@Adirockzz95
Copy link
Author

Usage:

  • Download file
  • Place it in your home directory
  • Make it executable by typing: chmod 755 JasperInstall.sh
  • Run file (WITHOUT sudo) : bash ./JasperInstall.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment