commit 7dc13bc7348ed6d91ceeb8f60c673611f9271d39
parent 01fe907883e8d482a7b1f28ad6e5a6131fb2fbac
Author: umhau <umhau@alum.gcc.edu>
Date: Mon, 19 Jun 2017 18:14:49 -0400
compress dependency install into cleaner install script.
Diffstat:
| M | README.md | | | 17 | +++++++++++++++-- |
| A | install.sh | | | 134 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| D | installdependencies.sh | | | 168 | ------------------------------------------------------------------------------- |
| D | installvmc.sh | | | 61 | ------------------------------------------------------------- |
| M | vmc | | | 8 | +++++--- |
5 files changed, 154 insertions(+), 234 deletions(-)
diff --git a/README.md b/README.md
@@ -24,8 +24,19 @@ Commands:
cd ~/Downloads
git clone https://github.com/umhau/vmc.git
cd ./vmc
- sudo bash ./installdependencies.sh ~/tools
- sudo bash ./installvmc.sh
+ sudo bash install.sh
+
+If the dependencies involved were already installed, use the following to
+install only the vmc program files (old versions will be automatically
+removed).
+
+ cd ./vmc
+ sudo bash install.sh -no-deps
+
+To remove vmc, run either of the following commands:
+
+ vmc -remove
+ vmc -uninstall
See use examples in the next section.
@@ -41,8 +52,10 @@ Create a new model, and create a new set of audio recordings.
vmc en-us -create /place/to/put/model -newrecordings /place/to/put/audio/files /dictation/file/location.txt 5
Import a previously created set of recordings, and adapt a preexisting model.
+
vmc en-us -adapt /extant/model/location -importrecordings /audio/files/location
+
File Structure
-------------------------------------------------------------------------------
diff --git a/install.sh b/install.sh
@@ -0,0 +1,134 @@
+#!/bin/bash
+#
+# USAGE =======================================================================
+#
+# bash install.sh -no-deps
+#
+# NOTES =======================================================================
+#
+# Copies the vmc packages into /opt/vmc, and puts the vmc script into
+# /usr/local/bin. Once there, vmc can be called (with its requisite
+# options) from anywhere with just vmc.sh.
+#
+# The script will use all the computer's cores to compile packages.
+#
+# A number of tools are installed to a user-specified location. These
+# include SphinxTrain and PocketSphinx. This installation folder is
+# presumed to be a direct subdirectory of the user's home directory.
+#
+# This may not work forever, as the CMU Sphinx packages are downloaded
+# from github, where they are under active development.
+#
+# SET VARIABLES ===============================================================
+
+# Absolute path to this script & containing folder. stackoverflow.com/q/242538
+script=$(readlink -f "$0"); scriptpath=$(dirname "$script")
+
+libdir=/opt/vmc/lib
+install_dir="/home/$USER/CMU_Sphinx"
+
+# check number of cores (speeds compilation)
+CORES=$(nproc --all 2>&1)
+
+# CMU Sphinx install location - my static repo or the official source?
+CMUsrc="cmusphinx" # or "umhau"
+
+# CHECK FOR PREVIOUS INSTALLATION =============================================
+
+if [ -d /opt/vmc/ ]; then
+ bash "$scriptpath/vmc -remove 1>/dev/null"; echo -n "Removed vmc"
+fi
+
+# INSTALL VMC DEPENDENCIES ====================================================
+if [ ! "$1" == '-no-deps' ]; then
+
+ echo -n "Installing dependencies. To continue, press [enter]."; read
+
+ if [ ! -d $install_dir ]; then mkdir $install_dir; fi
+
+ # let apt auto-detect the installation state of the dependencies
+ sudo apt-get install git swig perl bison libtool-bin automake autoconf -y
+ sudo apt-get install python-dev python3 python3-pyaudio -y
+
+ # check for and install sphinxbase
+ echo -n "Checking for SphinxBase...."
+ if [ ! -d $install_dir/sphinxbase/ ]; then
+ echo "installing..."; cd $install_dir
+ git clone "https://github.com/$CMUsrc/sphinxbase.git"
+ cd ./sphinxbase
+ ./autogen.sh --with-sphinxbase-build
+ ./configure
+ make -j $CORES
+ make -j $CORES check
+ sudo make -j $CORES install
+ sudo chown -R $USER: $install_dir # bug: dir had root ownership.
+ else
+ echo "SphinxBase already installed."
+ fi
+
+ # check for and install sphinxtrain
+ echo "Checking for sphinxtrain...."
+ if [ ! -d $install_dir/sphinxtrain/ ]; then
+ echo "installing..."; cd $install_dir
+ git clone "https://github.com/$CMUsrc/sphinxtrain.git"
+ cd ./sphinxtrain
+ ./autogen.sh
+ ./configure
+ make -j $CORES
+ sudo make -j $CORES install
+ sudo chown -R $USER: $install_dir # bug: dir had root ownership.
+ else
+ echo "SphinxTrain already installed."
+ fi
+
+ # check for and install pocketsphinx
+ echo -n "Checking for pocketsphinx..."
+ if [ ! -d $install_dir/pocketsphinx/ ]; then
+ echo "installing..."; cd $install_dir
+ git clone "https://github.com/$CMUsrc/pocketsphinx.git"
+ cd ./pocketsphinx
+ ./autogen.sh
+ ./configure
+ make -j $CORES clean all
+ make -j $CORES check
+ sudo make -j $CORES install
+ sudo chown -R $USER: $install_dir # bug: dir had root ownership.
+ else
+ echo "PocketSphinx already installed."
+ fi
+
+else echo -n "NOT installing dependencies. To continue, press [enter]."; read
+fi
+
+# MOVE VMC FILES ==============================================================
+
+# get sudo
+sudo ls 1>/dev/null; echo -en "\nInstalling vmc..."
+
+# create vmc directories
+sudo mkdir -p $libdir; sudo mkdir -p $libdir
+
+# move library
+sudo cp -r $scriptpath/lib/* $libdir/
+
+sudo tar -xf $scriptpath/lib/cmusphinx-en-us-ptm-5.2.tar.gz -C $libdir
+sudo mv $libdir/cmusphinx-en-us-ptm-5.2 $libdir/en-us
+
+# move vmc into user's path & set as executable
+sudo cp $scriptpath/vmc /usr/local/bin/vmc
+sudo chmod +x /usr/local/bin/vmc
+
+# move lmt into user's path & set as executable
+sudo cp $scriptpath/lmt /usr/local/bin/lmt
+sudo chmod +x /usr/local/bin/lmt
+
+# GET SPHINXTRAIN BINARIES ========================================================================
+
+# copy binary tools into model folder
+sudo cp /usr/local/libexec/sphinxtrain/bw $libdir
+sudo cp /usr/local/libexec/sphinxtrain/map_adapt $libdir
+sudo cp /usr/local/libexec/sphinxtrain/mk_s2sendump $libdir
+sudo cp /usr/local/libexec/sphinxtrain/mllr_solve $libdir
+
+echo "done."
+
diff --git a/installdependencies.sh b/installdependencies.sh
@@ -1,168 +0,0 @@
-#!/bin/bash
-#
-# USAGE
-#
-# bash installdependencies.sh [installation folder path]
-#
-# EXAMPLE
-#
-# bash installdependencies.sh ~/tools
-#
-# NOTES
-#
-# A number of tools are installed to a user-specified location. These include SphinxTrain
-# and PocketSphinx. This installation folder is presumed to be a direct subdirectory of the
-# user's home directory.
-#
-# The script will use all the computer's cores to compile packages.
-#
-# This may not work forever, as the CMU Sphinx packages are downloaded from github, where
-# they are under active development.
-#
-
-# VARIABLES =======================================================================================
-
-installation_directory=$1
-
-# PREPARATION =====================================================================================
-
-echo
-
-# check that installation folder has been specified
-if [ ! -n "$installation_directory" ]; then
- echo
- echo "**Error**: you must specify installation folder for CMU programs."
- echo "Folder should be specified relative to the home directory."
- echo "Recommended: 'bash install.sh tools'"
- exit 64
-fi
-
-# check number of cores (speeds compilation)
-CORES=$(nproc --all 2>&1)
-
-
-# make sure folder exists
-if [ ! -d $installation_directory ]; then
- mkdir $installation_directory
-fi
-
-# INSTALL CMU SPHINX DEPENDENCIES =================================================================
-
-# NOTE: I prefer to let apt detect prior installation. it makes the code much nicer to read.
-
-# needed for installations
-echo "Installing git..."
-sudo apt-get install git -y
-echo
-
-echo "Installing swig..."
-sudo apt-get install swig -y
-echo
-
-# used to build LM
-echo "Installing perl..."
-sudo apt-get install perl -y
-echo
-
-# needed for compiling
-echo "Installing bison..."
-sudo apt-get install bison -y
-echo
-
-# python development version: needed for sphinxbase
-echo "Installing python-dev..."
-sudo apt-get install python-dev -y
-echo
-
-# used for audio recordings
-echo "Installing python3-pyaudio..."
-sudo apt-get install python3-pyaudio -y
-echo
-
-# used in some scripts
-echo "Installing python3..."
-sudo apt-get install python3 -y
-echo
-
-echo "Installing libtool..."
-sudo apt-get install libtool-bin -y
-echo
-
-echo "Installing automake..."
-sudo apt-get install automake -y
-echo
-
-echo "Installing autoconf..."
-sudo apt-get install autoconf -y
-echo
-
-# INSTALL CMU SPHINX PACKAGES =====================================================================
-
-# check for and install sphinxbase
-echo -n "Checking for sphinxbase...."
-if [ ! -d $installation_directory/sphinxbase/ ]; then
- echo
- echo "installing..."
- cd $installation_directory
- git clone https://github.com/cmusphinx/sphinxbase.git
- cd ./sphinxbase
- ./autogen.sh --with-sphinxbase-build
- ./configure
- make -j $CORES
- make -j $CORES check
- sudo make -j $CORES install
- sudo chown -R $USER: $installation_directory # bug: dir had root ownership.
-else
- echo "Done."
- echo "SphinxBase already installed."
- echo
-fi
-
-# check for and install sphinxtrain
-echo -n "Checking for sphinxtrain...."
-if [ ! -d $installation_directory/sphinxtrain/ ]; then
- echo
- echo -n "installing..."
- cd $installation_directory
- git clone https://github.com/cmusphinx/sphinxtrain.git
- cd ./sphinxtrain
- ./autogen.sh
- ./configure
- make -j $CORES
- sudo make -j $CORES install
- sudo chown -R $USER: $installation_directory # bug: dir had root ownership.
- echo "Done."
-else
- echo "Done."
- echo "SphinxTrain already installed."
- echo
-fi
-
-
-# check for and install pocketsphinx
-echo -n "Checking for pocketsphinx..."
-if [ ! -d $installation_directory/pocketsphinx/ ]; then
- echo
- echo -n "installing..."
- cd $installation_directory
- git clone https://github.com/cmusphinx/pocketsphinx.git
- cd ./pocketsphinx
- ./autogen.sh
- ./configure
- make -j $CORES clean all
- make -j $CORES check
- sudo make -j $CORES install
- sudo chown -R $USER: $installation_directory # bug: dir had root ownership.
- echo "done."
-else
- echo "Done."
- echo "PocketSphinx already installed."
- echo
-fi
-
-echo "vmc dependency installations completed. See README for next steps."
-echo
-
-
-
-
diff --git a/installvmc.sh b/installvmc.sh
@@ -1,61 +0,0 @@
-#!/bin/bash
-#
-# USAGE =======================================================================
-#
-# bash installvmc.sh
-#
-# NOTES =======================================================================
-#
-# Copies the vmc packages into /opt/vmc, and puts the vmc script into
-# /usr/local/bin. Once there, vmc can be called (with its requisite
-# options) from anywhere with just vmc.sh.
-#
-# SET VARIABLES ===============================================================
-
-# Absolute path to this script & containing folder. stackoverflow.com/q/242538
-script=$(readlink -f "$0"); scriptpath=$(dirname "$script")
-
-libdir=/opt/vmc/lib
-
-# CHECK FOR PREVIOUS INSTALLATION =============================================
-
-if [ -d /opt/vmc/ ]; then
-
- bash "$scriptpath/vmc -remove 1>/dev/null"; echo -n "Removed vmc";
-
- # echo "vmc is already installed. To remove, run vmc -remove"; exit 1
-
-fi
-
-# MOVE VMC FILES ==============================================================
-
-# get sudo
-sudo ls 1>/dev/null; echo -en "\nInstalling vmc..."
-
-# create vmc directories
-sudo mkdir -p $libdir; sudo mkdir -p $libdir
-
-# move library
-sudo cp -r $scriptpath/lib/* $libdir/
-
-sudo tar -xf $scriptpath/lib/cmusphinx-en-us-ptm-5.2.tar.gz -C $libdir
-sudo mv $libdir/cmusphinx-en-us-ptm-5.2 $libdir/en-us
-
-# move vmc into user's path & set as executable
-sudo cp $scriptpath/vmc /usr/local/bin/vmc
-sudo chmod +x /usr/local/bin/vmc
-
-# move lmt into user's path & set as executable
-sudo cp $scriptpath/lmt /usr/local/bin/lmt
-sudo chmod +x /usr/local/bin/lmt
-
-# GET SPHINXTRAIN BINARIES ========================================================================
-
-# copy binary tools into model folder
-sudo cp /usr/local/libexec/sphinxtrain/bw $libdir
-sudo cp /usr/local/libexec/sphinxtrain/map_adapt $libdir
-sudo cp /usr/local/libexec/sphinxtrain/mk_s2sendump $libdir
-sudo cp /usr/local/libexec/sphinxtrain/mllr_solve $libdir
-
-echo "done."
-
diff --git a/vmc b/vmc
@@ -53,11 +53,13 @@ model_name="$1" # i.e. 'en-us'
model_location="$3" # i.e. /usr/local/lib/python2.7/dist-packages/pocketsphinx/model/en-us
audio_folder="$5" # i.e. ~/.psyche/audio
-if [ $4 == '-newrecordings' ] || [ $4 == '-addrecordings' ]; then dict_file="$6"; reps="$7";
-else echo "Bad options given. Run: 'nano /usr/local/bin/vmc'."; exit 1; fi
+if [ $4 == '-newrecordings' ] || [ $4 == '-addrecordings' ]; then
+ dict_file="$6"; reps="$7"
+else
+ echo "Bad options given. Run: 'nano /usr/local/bin/vmc'."; exit 1
+fi
current_number_of_recordings="0" # changed below, if there are any.
-
libdir="/opt/vmc/lib"
# COMMANDS ====================================================================