?? festvoxtofreetts.sh
字號:
#!/bin/bash# Portions Copyright 2003 Sun Microsystems, Inc.# Portions Copyright 1999-2003 Language Technologies Institute,# Carnegie Mellon University.# All Rights Reserved. Use is subject to license terms.## See the file "license.terms" for information on usage and# redistribution of this file, and for a DISCLAIMER OF ALL# WARRANTIES.usage() { echo "Usage: $0 <voicedir> [lpc | sts | mcep | idx | install | compile]" echo " $0 --help" echo "Converts a festvox voice into FreeTTS format." echo echo "--help Show this message." echo "<voicedir> The directory containing the festvox voice data." echo " This directory must have a wav/ subdirectory." echo "lpc,sts,mcep,... The second parameter may explicitly run an" echo " individual stage of the conversion process." echo echo "The ESTDIR environment variable must point to the directory" echo " containing a compiled version of the Edinbourough Speech Tools." echo "festival, ant, java, and javac must be in your path." echo echo "Running with no second parameter will run the stages in order:" echo " (lpc,sts,mcep,idx,install,compile)." echo "Note that some stages may rely on the execution of previous stages." echo echo "It is recommended to execute the conversion process without" echo " the second parameter." exit -1}if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then usagefiif [ -d "$1" ] && [ -d "$1/wav" ]; then VOICEDIR="$1"else usagefi. $VOICEDIR/etc/voice.defs# Description of freetts-specific properties. Try to read them# from voice dir, or assume default values. This is only needed# for the "install" and "compile" steps.if [ -e "$VOICEDIR/etc/freetts.properties" ]; then . $VOICEDIR/etc/freetts.propertieselse # defaults VP_NAME="$FV_NAME" VP_GENDER="NEUTRAL" VP_AGE="NEUTRAL" VP_DESCRIPTION="description not available" VP_FULL_NAME="$FV_VOICENAME" VP_LOCALE="en_US" LOCALEPATH="en/us" VOICETARGETBASE="com/sun/speech/freetts"fiif [ "$2" = "compile" ]; then if [ "$FV_TYPE" = "diphone" ]; then ant -Ddiphone_voice=$VP_FULL_NAME -Duser_voice_base_path=$VOICETARGETBASE/$LOCALEPATH -find build.xml elif [ "$FV_TYPE" = "ldom" ] || [ "$FV_TYPE" = "clunits" ]; then ant -Dclunit_voice=$VP_FULL_NAME -Duser_voice_base_path=$VOICETARGETBASE/$LOCALEPATH -find build.xml fi exit 0fiif [ ! "$ESTDIR" ]; then echo "environment variable ESTDIR is unset" echo "set it to your local speech tools directory e.g." echo ' bash$ export ESTDIR=/home/<username>/projects/speech_tools/' echo or echo ' csh% setenv ESTDIR /home/<username>/projects/speech_tools/' echo usagefiif [ ! -f $VOICEDIR/etc/voice.defs ]; then echo "Can't find $VOICEDIR/etc/voice.defs file" echo "don't know what voice to convert" echo echo "If the voice directory is correct, you could try" echo " festvox/src/general/guess_voice_defs to generate it." echo echo "Setup for conversion of $1 to flite FAILED" echo usagefiif ! festival --version; then echo echo "ERROR: festival not in path." echo usagefiif ! java -version >/dev/null 2>/dev/null || ! javac -help 2>/dev/null; then echo echo "ERROR: java and javac must be in path." echo usagefiif ! ant -version; then echo echo "ERROR: ant not in path." echo usagefi# perform conversionif [ "$2" = "" ]; then # perform each step individually if ! $0 $VOICEDIR lpc; then exit $? fi if ! $0 $VOICEDIR sts; then exit $? fi if [ "$FV_TYPE" != "diphone" ] then if ! $0 $VOICEDIR mcep; then exit $? fi fi if ! $0 $VOICEDIR idx; then exit $? fi if ! $0 $VOICEDIR "install"; then exit $? fi if ! $0 $VOICEDIR compile; then exit $? fi echo echo "Conversion process complete"fi# The scheme and java files should be in the same directory as this scriptHELPERDIR=`dirname $0`# Make sure that HELPERDIR contains an absolute path:echo $HELPERDIR | grep "^/" > /dev/null || HELPERDIR=`pwd`/$HELPERDIR# This assumes that FreeTTS is configured with this directory structureFREETTSDIR="$HELPERDIR/../.."# We need some files from the ArcticToFreeTTS directory...ARCTICDIR="$FREETTSDIR/tools/ArcticToFreeTTS"#This is where some temperary files are generated as well as the final voiceOUTDIR=$VOICEDIR/FreeTTSmkdir $OUTDIR >/dev/null 2>/dev/null(cd $ARCTICDIR; mkdir -p classes; cd src; javac -d ../classes *.java)if [ "$2" = "lpc" ]; then echo Creating lpc files mkdir -p $VOICEDIR/lpc (cd $VOICEDIR bin/make_lpc wav/*.wav ) echo Creating lpc/lpc.params for file in $VOICEDIR/lpc/*.lpc; do $ESTDIR/bin/ch_track -otype est_ascii $file done | sed '1,/EST_Header_End/d' | awk 'BEGIN {min=0; max=0;} { for (i=4; i<=NF; i++) { if ($i < min) min = $i; if ($i > max) max = $i; } } END { printf("LPC_MIN=%f\n",min); printf("LPC_MAX=%f\n",max); printf("LPC_RANGE=%f\n",max-min); }' > $VOICEDIR/lpc/lpc.paramsfi# build sts filesif [ "$2" = "sts" ]; then if [ "$FV_TYPE" = "diphone" ]; then # need to create scheme-formatted sts files for diphones echo "Finding STS files" . $VOICEDIR/lpc/lpc.params mkdir $VOICEDIR/sts 2>/dev/null # compile FindSTS CLASSFILES="FindSTS.class LPC.class STS.class Wave.class Utility.class" (cd $HELPERDIR javac FindSTS.java jar -cf FindSTS.jar $CLASSFILES rm -f $CLASSFILES 2>/dev/null) for f in $VOICEDIR/lpc/*.lpc; do fname=`basename $f .lpc` echo $fname STS java -cp "$HELPERDIR/FindSTS.jar" FindSTS $LPC_MIN $LPC_RANGE $f \ $VOICEDIR/wav/$fname.wav $VOICEDIR/sts/$fname.sts done else # create STS files in the same format as for ARCTIC voices for clunits # and limited domain voices (cd $VOICEDIR echo "Creating short term signal (STS) files in sts/*.sts" mkdir -p sts java -cp $ARCTICDIR/classes FindSTS \ `find wav -type f | cut -f2 -d/ | cut -f1 -d.` ) fifiif [ "$2" = "mcep" ]; then # MCEP coefficients are not used for diphones echo Creating mcep/mcep.params and converting mcep files to text for file in $VOICEDIR/mcep/*.mcep; do echo $file MCEP $ESTDIR/bin/ch_track -otype est_ascii $file > $file.txt cat $file.txt done | sed '1,/EST_Header_End/d' | awk 'BEGIN {min=0; max=0;} { for (i=4; i<=NF; i++) { if ($i < min) min = $i; if ($i > max) max = $i; } } END { printf("MCEP_MIN=%f\n",min); printf("MCEP_MAX=%f\n",max); printf("MCEP_RANGE=%f\n",max-min); }' > $VOICEDIR/mcep/mcep.paramsfiidx_non_diphone() {echo Creating unit index(cd $VOICEDIR echo Creating $OUTDIR/misc.txt festival -b \ festvox/$FV_FULLVOICENAME.scm \ $ARCTICDIR/scheme/dump_misc.scm \ "(begin (voice_${FV_FULLVOICENAME}) (dump_misc))" > \ $OUTDIR/misc.txt# UnitDatabase outputs its own info... java -cp $ARCTICDIR/classes UnitDatabase \ festival/clunits/${FV_VOICENAME}.catalogue \ `find wav -type f | cut -f2 -d/ | cut -f1 -d.`echo Creating $OUTDIR/trees.txtfestival -b \ festvox/$FV_FULLVOICENAME.scm \ $ARCTICDIR/scheme/dump_trees.scm \ "(begin (voice_${FV_FULLVOICENAME}) (dump_trees))" > \ $OUTDIR/trees.txtecho Creating $OUTDIR/weights.txtfestival -b \ festvox/$FV_FULLVOICENAME.scm \ $ARCTICDIR/scheme/dump_join_weights.scm \ "(begin (voice_${FV_FULLVOICENAME}) (dump_join_weights))" > \ $OUTDIR/weights.txtecho Combining these files into $OUTDIR/$FV_VOICENAME.txt(cd $OUTDIR; cat misc.txt unit_catalog.txt trees.txt unit_index.txt sts.txt mcep.txt weights.txt > $FV_VOICENAME.txt))}idx_diphone() { echo "Building diphone index" sed '1,/EST_Header_End/d' $VOICEDIR/dic/*.est | awk '{printf("( %s )\n",$0)}' >$VOICEDIR/dic/diphidx.unsorted.scm festival --heap 5000000 -b \ $HELPERDIR/qsort.scm \ '(begin (set! diphindex (load "'$VOICEDIR/dic/diphidx.unsorted.scm'" t)) (set! diphindex (qsort diphindex carstring<? carstring=?)) (while (not (null? diphindex)) (set! x (car diphindex)) (format t "( %l %l %l %l %l ) \n" (nth 0 x) (nth 1 x) (nth 2 x) (nth 3 x) (nth 4 x)) (set! diphindex (cdr diphindex)) ))' > $VOICEDIR/dic/diphidx.scm festival --heap 5000000 -b \ $HELPERDIR/FestVoxDiphoneToFreeTTS.scm \ '(dump_diphone "'$FV_VOICENAME'" "'$VOICEDIR'" "'$OUTDIR'" "header.txt" "data.txt" "'$VOICEDIR'/dic/diphidx.scm")' # parentheses allow script to only temporarily change to $OUTDIR (cd $OUTDIR rm -f README 2>/dev/null rm -f $FV_FULLVOICENAME.txt 2>/dev/null echo "The data for the voice $FV_FULLVOICENAME is stored in" > README echo "$FV_FULLVOICENAME.txt All other files may be ignored." >> README echo "*** Generated by $0 $1 $2" > $FV_FULLVOICENAME.txt echo "*** clunits " `date` >> $FV_FULLVOICENAME.txt cat header.txt data.txt >> $FV_FULLVOICENAME.txt )}if [ "$2" = "idx" ]; then if [ "$FV_TYPE" = "diphone" ]; then idx_diphone else idx_non_diphone fifisetGender() { while true; do echo "Please the number corresponding to the gender of this voice:" echo " 0 <Cancel>" echo " 1 Neutral" echo " 2 Male" echo " 3 Female" echo " Q <Quit>: Abort the conversion process." read if [ "$REPLY" = "0" ]; then break elif [ "$REPLY" = "1" ]; then VP_GENDER="NEUTRAL"
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -