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
|
#!/bin/sh
###########################################################################
## ##
## Language Technologies Institute ##
## Carnegie Mellon University ##
## Copyright (c) 2002 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
## ##
## Build a flite voice from a festvox voice ##
## ##
## C files are built into flite/ ##
## ##
###########################################################################
FLITEDIR=__FLITEDIR__
FIND_STS=$FLITEDIR/tools/find_sts
. ./etc/voice.defs
if [ $# = 0 ]
then
$0 lpc
$0 sts
if [ "$FV_TYPE" != "diphone" ]
then
$0 mcep
fi
$0 idx
exit
fi
# Build lpc coefficients
if [ "$1" = "lpc" ]
then
echo "Finding LPC coefficients"
for i in wav/*.wav
do
./bin/make_lpc $i
done
echo "Finding LPC min, max and range"
# make lpc.params file
for i in lpc/*.lpc
do
$ESTDIR/bin/ch_track -otype est_ascii $i
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);
}' >lpc/lpc.params
fi
# build sts files
if [ "$1" = "sts" ]
then
echo "Finding STS files"
. ./lpc/lpc.params
for i in lpc/*.lpc
do
fname=`basename $i .lpc`
echo $fname STS
$FIND_STS $LPC_MIN $LPC_RANGE $i wav/$fname.wav sts/$fname.sts
done
fi
# build mcep (params)
if [ "$1" = "mcep" ]
then
echo "Finding MCEP min max and range"
for i in mcep/*.mcep
do
$ESTDIR/bin/ch_track -otype est_ascii $i
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("(set! mcep_min %f)\n",min);
printf("(set! mcep_max %f)\n",max);
printf("(set! mcep_range %f)\n",max-min);
}' >mcep/mcep.params.scm
fi
# build index file
if [ "$1" = "idx" ]
then
if [ "$FV_TYPE" != "diphone" ] # clunits or ldom
then
echo "Building clunits/ldom index"
sed '1,/EST_Header_End/d' festival/clunits/$FV_VOICENAME.catalogue |
awk 'BEGIN {p="CLUNIT_NONE";}
{if ((NR > 1) && (t != "0_0"))
{
n = split(t,bits,"_");
unit_type = substr(t,1,length(t)-(length(bits[n])+1));
unit_occur = bits[n];
if ((t == "0_0") || (f != $2) || ($1 == "0_0"))
printf("%s_%05d -- ( %s %s %s )\n",unit_type,unit_occur,line,p,"CLUNIT_NONE");
else
printf("%s_%05d -- ( %s %s unit_%s )\n",unit_type,unit_occur, line,p,$1);
}
line = $0;
if ((t == "0_0") || (f != $2))
p = "CLUNIT_NONE";
else
p=sprintf("unit_%s",t);
t=$1;
f=$2;
}
END { if (t != "0_0")
{
n = split(t,bits,"_");
unit_type = substr(t,1,length(t)-(length(bits[n])+1));
unit_occur = bits[n];
printf("%s_%05d -- ( %s %s %s )\n", unit_type,unit_occur,line,p,"CLUNIT_NONE");
} }' |
cat >festival/clunits/$FV_VOICENAME.scm
cat festival/clunits/$FV_VOICENAME.scm |
$FLITEDIR/tools/flite_sort |
sed 's/^.* -- //' >festival/clunits/$FV_VOICENAME.unitordered.scm
cat festival/clunits/$FV_VOICENAME.scm |
sed 's/^.* -- //' >festival/clunits/$FV_VOICENAME.fileordered.scm
rm -f flite/$FV_VOICENAME"_lpc"*
rm -f flite/$FV_VOICENAME"_mcep"*
festival --heap 5000000 -b $FLITEDIR/tools/make_clunits.scm \
$FLITEDIR/tools/make_cart.scm \
$FLITEDIR/tools/make_vallist.scm \
mcep/mcep.params.scm \
'(clunits_convert "'$FV_VOICENAME'"
"festival/clunits/'$FV_VOICENAME'.fileordered.scm"
"festival/clunits/'$FV_VOICENAME'.unitordered.scm"
"festival/trees/'$FV_VOICENAME'.tree"
"."
"flite/")'
fi
if [ "$FV_TYPE" = "diphone" ]
then
echo "Building diphone index"
sed '1,/EST_Header_End/d' dic/*.est |
awk '{printf("%s ( %s )\n",$1,$0)}' |
$FLITEDIR/tools/flite_sort |
sed 's/^.* (/(/' >dic/diphidx.scm
festival --heap 5000000 -b $FLITEDIR/tools/make_didb.scm \
'(diphtoC "dic/diphidx.scm" "'$FV_VOICENAME'" "sts" "flite")'
fi
echo "flite_build complete. You can compile the generated voice by"
echo " cd flite; make"
fi
|