‹ projects

vmc

a voice model creator for CMU Sphinx
Log | Files | Refs | README | LICENSE

commit 39157359e693bcc2767318baa175de8dcb1d594d
parent 9dad061fbabfed66efa939997adb99643b31e82c
Author: umhau <umhau@alum.gcc.edu>
Date:   Wed, 14 Jun 2017 16:46:13 -0400

rename primary files vmc.sh and lmt.sh to vmc and lmt.

Diffstat:
MREADME.md | 6+++---
Minstallvmc.sh | 8++++----
Almt | 36++++++++++++++++++++++++++++++++++++
Dlmt.sh | 36------------------------------------
Muninstallvmc.sh | 6+++---
Avmc | 160+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dvmc.sh | 160-------------------------------------------------------------------------------
7 files changed, 206 insertions(+), 206 deletions(-)

diff --git a/README.md b/README.md @@ -40,11 +40,11 @@ Usage instructions Example usage, recording new audio with 5 repetitions of each sentence: - vmc.sh new_model -record ~/Downloads/sentences.txt ~/projects/new_model 5 + vmc new_model -record ~/Downloads/sentences.txt ~/projects/new_model 5 Example usage, importing previously created audio files: - vmc.sh ccmodel -import audio_files cc.list ~/tools/ccmodel + vmc ccmodel -import audio_files cc.list ~/tools/ccmodel Note that the model name and the name of the model folder should be the same. Also note the repetitions specification is optional; it defaults to 1. @@ -52,7 +52,7 @@ Also note the repetitions specification is optional; it defaults to 1. The model folder will contain all necessary files to run PocketSphinx with the newly created custom voice model. -Note that dependencies are not checked when running vmc.sh. To check +Note that dependencies are not checked when running vmc. To check dependencies, see the section above. Background diff --git a/installvmc.sh b/installvmc.sh @@ -47,12 +47,12 @@ sudo mv $tdir/cmusphinx-en-us-ptm-5.2 $tdir/en-us sudo cp -r $scriptpath/functions/* $fdir/ # move vmc into user's path & set as executable -sudo cp $scriptpath/vmc.sh /usr/local/bin/vmc.sh -sudo chmod +x /usr/local/bin/vmc.sh +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.sh /usr/local/bin/lmt.sh -sudo chmod +x /usr/local/bin/lmt.sh +sudo cp $scriptpath/lmt /usr/local/bin/lmt +sudo chmod +x /usr/local/bin/lmt # GET SPHINXTRAIN BINARIES ======================================================================== diff --git a/lmt b/lmt @@ -0,0 +1,36 @@ +#!/bin/bash +# +# DESCRIPTION +# +# Given a list of sentences, create a statistical language model. +# +# USAGE: lmt lm-training-file lm-file-name output-location +# +# VARIABLES =================================================================== + +sentence_list_file=$1; output_lm_file_name=$2; save_directory=$3; + +fdir=/opt/vmc/lib + +# CHECK IF HELP NEEDED ======================================================== + +if [[ -z $1 ]]; then + + echo + echo -e "USAGE: \tlmt " + echo + echo -e "\tsentence_list_file\t(input file with sample sentences)" + echo -e "\toutput_lm_file_name\t(desired base name of output lm file)" + echo -e "\tsave_directory\t\t(location to save the ouput file into)" + echo + + exit 1 + +fi + +# COMMANDS ==================================================================== + +# build language model +bash $fdir/buildLM.sh $sentence_list_file $output_lm_file_name $save_directory + + diff --git a/lmt.sh b/lmt.sh @@ -1,36 +0,0 @@ -#!/bin/bash -# -# DESCRIPTION -# -# Given a list of sentences, create a statistical language model. -# -# USAGE: lmt.sh lm-training-file lm-file-name output-location -# -# VARIABLES =================================================================== - -sentence_list_file=$1; output_lm_file_name=$2; save_directory=$3; - -fdir=/opt/vmc/lib - -# CHECK IF HELP NEEDED ======================================================== - -if [[ -z $1 ]]; then - - echo - echo -e "USAGE: \tlmt.sh " - echo - echo -e "\tsentence_list_file\t(input file with sample sentences)" - echo -e "\toutput_lm_file_name\t(desired base name of output lm file)" - echo -e "\tsave_directory\t\t(location to save the ouput file into)" - echo - - exit 1 - -fi - -# COMMANDS ==================================================================== - -# build language model -bash $fdir/buildLM.sh $sentence_list_file $output_lm_file_name $save_directory - - diff --git a/uninstallvmc.sh b/uninstallvmc.sh @@ -1,14 +1,14 @@ #!/bin/bash # -# USAGE: bash uninstallvmc.sh +# USAGE: bash uninstallvmc # # DELETE EVERYTHING =========================================================== sudo rm -rf /opt/vmc -sudo rm -f /usr/local/bin/vmc.sh +sudo rm -f /usr/local/bin/vmc -sudo rm -f /usr/local/bin/lmt.sh +sudo rm -f /usr/local/bin/lmt echo "vmc removed." diff --git a/vmc b/vmc @@ -0,0 +1,160 @@ +#!/bin/bash +# +# DESCRIPTION +# +# Given a sentence file and (optionally) prerecorded audio files, produce +# a voice model in a specified location. Indicate whether to record +# (-record) or import (-import) the audio files. +# +# The statistical language model is now produced separately, run +# +# $ lmt +# +# to see what the parameters are. +# +# USAGE +# +# vmc +# model-name used to name most of the internal files +# +# [ -record OR -import audio/file/directory ] +# +# vm-training-file sentences the user should record for +# training purposes +# +# output-folder this is a complete file path. If +# adapting in-place, this is the same as +# the acoustic-model (input) folder. +# +# [reps] how many times to get a recording of +# each sentence +# +# acoustic-model Location of acoustic model to start +# with. (this is a complete file path, +# not including 'en-us'.) Optional. +# +# -adapt_in_place Only relevant if an acoustic model has +# been given to start with. Adapt, and +# do not copy, the given acoustic model. +# +# DEPENDENCIES +# +# CMU Sphinx, Python 3 (& 2.7), Perl, and other misc. packages. +# +# NOTES +# +# The output folder is intended to be the location of the voice model, +# once completed. +# +# The [reps] variable at the end specifies how many times to request a +# recording of each entry in the sentence file. It is optional, as it is +# placed at the end of the list of parameters and the script will not +# fail if it is not specified. +# +# Having been installed to /usr/local/bin, this command can be called +# from anywhere. +# +# After installation, a keyphrase list should be added in order to use +# the voice model for keyword spotting. +# + +# VARIABLES =================================================================== + +export LD_LIBRARY_PATH=/usr/local/lib +# set path to include sphinx library location +# jrmeyer.github.io/installation/2016/01/09/Installing-CMU-Sphinx-on-Ubuntu.html + +if [[ $2 = '-record' ]]; then + + vm_training_file=$3; output_folder=$4 + + if [[ -n $5 ]]; then iterations=$5; else iterations=1; fi + +elif [[ $2 = '-import' ]]; then + + audio_file_directory=$3; sentence_file=$4; output_folder=$5; iterations=1 + +else + + echo + echo -e "USAGE: \tvmc " + echo + echo -e "\tmodel-name\t\t(used to name most of the internal files)" + echo -e "\t[ -record OR -import audio/file/directory ]" + echo -e "\tvm-training-file\t(sentences for the user to record)" + echo -e "\toutput-folder\t\t(this is a complete file path)" + echo -e "\t[reps]\t\t\t(number of voice recordings per sentence)" + echo + + exit 1 + +fi + +model_name=$1 + +audio_folder=$output_folder/audio + +tdir=/opt/vmc/tools; fdir=/opt/vmc/functions + + +# COMMANDS ==================================================================== + +# OBTAIN REQUISITE FILES ------------------------------------------------------ + +echo +echo "Collecting required files..." + +# get audio files and put them where they go +if [[ $2 = '-record' ]]; then + + sudo mkdir -p $audio_folder + + sudo python3 $fdir/getaudio.py $vm_training_file $audio_folder $iterations $model_name + + echo "Recorded audio files saved into $audio_folder. They can be reused." + +elif [[ $2 = '-import' ]]; then + + sudo mkdir -p $audio_folder + + sudo cp -a $audio_file_directory/*.wav $audio_folder/ + +fi + +# copy default acoustic model - or not. +if [[ $2 = '-adapt_in_place' ]]; then + + +if [ -n "$6" ]; then + echo "Pulling base acoustic model from $6" + read -p "Press enter to continue, or CTRL-C to exit" + sudo cp -r $installation_directory/en-us $output_folder +else + echo "Using default base acoustic model." + sudo cp -r $tdir/en-us $output_folder +fi + +# PRODUCE DERIVATIVE FILES ---------------------------------------------------- + +echo +echo "Producing sentence file derivatives..." + +# get derivatives of sentence file +sudo python3 $fdir/format_text.py $vm_training_file $model_name $output_folder $iterations + +echo +echo "Producing audio file derivatives..." + +# get derivatives of audio files +sudo bash $fdir/acousticfiles.sh $audio_folder $output_folder/$model_name.fileids + +# CREATE MODELS --------------------------------------------------------------- + +echo +echo "Creating voice model..." + +# build voice model +sudo bash $fdir/voicemodel.sh $model_name $output_folder $audio_folder $output_folder + +echo +echo "Process complete. New acoustic voice model saved into $output_folder" diff --git a/vmc.sh b/vmc.sh @@ -1,160 +0,0 @@ -#!/bin/bash -# -# DESCRIPTION -# -# Given a sentence file and (optionally) prerecorded audio files, produce -# a voice model in a specified location. Indicate whether to record -# (-record) or import (-import) the audio files. -# -# The statistical language model is now produced separately, run -# -# $ lmt.sh -# -# to see what the parameters are. -# -# USAGE -# -# vmc.sh -# model-name used to name most of the internal files -# -# [ -record OR -import audio/file/directory ] -# -# vm-training-file sentences the user should record for -# training purposes -# -# output-folder this is a complete file path. If -# adapting in-place, this is the same as -# the acoustic-model (input) folder. -# -# [reps] how many times to get a recording of -# each sentence -# -# acoustic-model Location of acoustic model to start -# with. (this is a complete file path, -# not including 'en-us'.) Optional. -# -# -adapt_in_place Only relevant if an acoustic model has -# been given to start with. Adapt, and -# do not copy, the given acoustic model. -# -# DEPENDENCIES -# -# CMU Sphinx, Python 3 (& 2.7), Perl, and other misc. packages. -# -# NOTES -# -# The output folder is intended to be the location of the voice model, -# once completed. -# -# The [reps] variable at the end specifies how many times to request a -# recording of each entry in the sentence file. It is optional, as it is -# placed at the end of the list of parameters and the script will not -# fail if it is not specified. -# -# Having been installed to /usr/local/bin, this command can be called -# from anywhere. -# -# After installation, a keyphrase list should be added in order to use -# the voice model for keyword spotting. -# - -# VARIABLES =================================================================== - -export LD_LIBRARY_PATH=/usr/local/lib -# set path to include sphinx library location -# jrmeyer.github.io/installation/2016/01/09/Installing-CMU-Sphinx-on-Ubuntu.html - -if [[ $2 = '-record' ]]; then - - vm_training_file=$3; output_folder=$4 - - if [[ -n $5 ]]; then iterations=$5; else iterations=1; fi - -elif [[ $2 = '-import' ]]; then - - audio_file_directory=$3; sentence_file=$4; output_folder=$5; iterations=1 - -else - - echo - echo -e "USAGE: \tvmc.sh " - echo - echo -e "\tmodel-name\t\t(used to name most of the internal files)" - echo -e "\t[ -record OR -import audio/file/directory ]" - echo -e "\tvm-training-file\t(sentences for the user to record)" - echo -e "\toutput-folder\t\t(this is a complete file path)" - echo -e "\t[reps]\t\t\t(number of voice recordings per sentence)" - echo - - exit 1 - -fi - -model_name=$1 - -audio_folder=$output_folder/audio - -tdir=/opt/vmc/tools; fdir=/opt/vmc/functions - - -# COMMANDS ==================================================================== - -# OBTAIN REQUISITE FILES ------------------------------------------------------ - -echo -echo "Collecting required files..." - -# get audio files and put them where they go -if [[ $2 = '-record' ]]; then - - sudo mkdir -p $audio_folder - - sudo python3 $fdir/getaudio.py $vm_training_file $audio_folder $iterations $model_name - - echo "Recorded audio files saved into $audio_folder. They can be reused." - -elif [[ $2 = '-import' ]]; then - - sudo mkdir -p $audio_folder - - sudo cp -a $audio_file_directory/*.wav $audio_folder/ - -fi - -# copy default acoustic model - or not. -if [[ $2 = '-adapt_in_place' ]]; then - - -if [ -n "$6" ]; then - echo "Pulling base acoustic model from $6" - read -p "Press enter to continue, or CTRL-C to exit" - sudo cp -r $installation_directory/en-us $output_folder -else - echo "Using default base acoustic model." - sudo cp -r $tdir/en-us $output_folder -fi - -# PRODUCE DERIVATIVE FILES ---------------------------------------------------- - -echo -echo "Producing sentence file derivatives..." - -# get derivatives of sentence file -sudo python3 $fdir/format_text.py $vm_training_file $model_name $output_folder $iterations - -echo -echo "Producing audio file derivatives..." - -# get derivatives of audio files -sudo bash $fdir/acousticfiles.sh $audio_folder $output_folder/$model_name.fileids - -# CREATE MODELS --------------------------------------------------------------- - -echo -echo "Creating voice model..." - -# build voice model -sudo bash $fdir/voicemodel.sh $model_name $output_folder $audio_folder $output_folder - -echo -echo "Process complete. New acoustic voice model saved into $output_folder"