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
|
#!/bin/sh
extension=".au"
encoding="mulaw"
engine=none
voice=""
text=""
file=""
opts=""
last=""
if test -z "$*" ; then
echo "*** no options"
exit -1
fi
for opt in $* ; do
if test ! -z "$text" ; then
text="$text $opt"
continue
fi
case "$opt" in
*-theta)
engine="theta"
opt=""
;;
*-encoding)
lastopt="-encoding"
opt=""
;;
*-file)
if test ! -z "$file" ; then
echo "*** file already selected"
exit -1
fi
lastopt="-file"
opt=""
;;
*-voice)
if test ! -z "$voice" ; then
echo "*** voice already selected"
exit -1
fi
lastopt="-voice"
opt=""
;;
*-theta-voice)
if test ! -z "$voice" ; then
echo "*** voice already selected"
exit -1
fi
engine="theta"
lastopt="-voice"
opt=""
;;
*-theta-voice=*)
if test ! -z "$voice" ; then
echo "*** voice already selected"
exit -1
fi
engine="theta"
lastopt="-voice"
opt=`echo $opt | sed s/.theta-voice=//`
;;
*-encoding=*)
lastopt="-encoding"
opt=`echo $opt | sed s/.encoding=//`
;;
*-voice=*)
if test ! -z "$voice" ; then
echo "*** voice already selected"
exit -1
fi
lastopt="-voice"
opt=`echo $opt | sed s/.voice=//`
;;
*-file=*)
if test ! -z "$file" ; then
echo "*** file already selected"
exit -1
fi
lastopt="-file"
opt=`echo $opt | sed s/.file=//`
;;
*)
if test -z "$lastopt" ; then
if test -z "$file" ; then
lastopt="-file"
else
text="$text $opt"
opt=""
fi
fi
;;
esac
if test ! -z "$opt" ; then
case "$lastopt" in
-voice)
voice=$opt
;;
-file)
file=$opt
case $file in
*.au|*.wav)
;;
*.al)
encoding="alaw"
;;
*.ul)
encoding="mulaw"
;;
*.raw)
encoding="linear"
;;
*)
file=$file.au
;;
esac
;;
-encoding)
case "$opt" in
mulaw|ulaw|alaw|linear|gsm)
encoding="$opt"
;;
*)
echo "*** unknown or unsupported encoding $opt"
exit -1
;;
esac
;;
esac
lastopt=""
fi
done
if test "$engine" == "none" ; then
echo "*** no tts engine selected"
exit -1
fi
if test -z "$file" ; then
echo "*** no file selected for output"
exit -1
fi
if test -z "$text" ; then
echo "*** no text for output"
exit -1
fi
case "$engine" in
theta)
case "$voice" in
male)
voice="-N Frank"
;;
female)
voice="-N Emily"
;;
*)
voice="-N $voice"
;;
esac
format="$file-$encoding"
case $format in
*.raw-linear|*.wav-linear)
/opt/theta/bin/theta -c 1 -F 8000 -o $file $voice "'$text'"
;;
*)
/opt/theta/bin/theta -c 1 -F 8000 -o .theta.wav $voice "'$text'"
audiotool --build -encoding=$encoding $file .theta.wav
rm -f .theta.wav
;;
esac
;;
*)
echo "*** unknown tts engine"
exit -1
esac
exit 0
|