Voice related changes:

- It's now possible to select multiple languages to build
- Added encoder and TTS engine configuration to configure (per-language)


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14309 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonas Häggqvist 2007-08-13 12:21:16 +00:00
parent 414ee9fcc5
commit 58537b43e6
3 changed files with 94 additions and 58 deletions

123
tools/configure vendored
View file

@ -284,8 +284,25 @@ whichadvanced () {
echo "done" echo "done"
if [ "yes" = "$voice" ]; then if [ "yes" = "$voice" ]; then
voiceconfig toolset="${toolset} voicefont wavtrim"
toolset="${toolset} voicefont wavtrim"
# Ask about languages to build
echo "Select a number for the language to use (default is english)"
echo "You may enter a comma-separated list of languages to build"
picklang
voicelanguage=`whichlang`
if [ -z "$voicelanguage" ]; then
# pick a default
voicelanguage="english"
fi
echo "Voice language set to $voicelanguage"
# Configure encoder and TTS engine for each language
for thislang in `echo $voicelanguage | sed 's/,/ /g'`; do
voiceconfig "$thislang"
done
fi fi
if [ "yes" = "$use_debug" ]; then if [ "yes" = "$use_debug" ]; then
debug="-DDEBUG" debug="-DDEBUG"
@ -304,8 +321,10 @@ whichadvanced () {
fi fi
} }
# Configure voice settings
voiceconfig () { voiceconfig () {
echo "Building voice for $archos" thislang=$1
echo "Building $thislang voice for $archos. Select options"
echo "" echo ""
if [ "`which flite`" != "" ]; then if [ "`which flite`" != "" ]; then
@ -377,6 +396,13 @@ voiceconfig () {
esac esac
echo "Using $TTS_ENGINE for TTS" echo "Using $TTS_ENGINE for TTS"
# Allow the user to input manual commandline options
printf "Enter $TTS_ENGINE options (enter for defaults `echo $TTS_OPTS |sed 's/.*=//'`): "
USER_TTS_OPTS=`input`
if [ -n "$USER_TTS_OPTS" ]; then
TTS_OPTS="`echo $TTS_OPTS | sed 's/=.*//'`=\"$USER_TTS_OPTS\""
fi
echo "" echo ""
if [ "`which oggenc`" != "" ]; then if [ "`which oggenc`" != "" ]; then
@ -402,37 +428,46 @@ voiceconfig () {
fi fi
if [ "$LAME" = "" ]; then if [ "$LAME" = "" ]; then
echo "You need to have Lame installed to build voice files" echo "You currently need to have Lame installed to build voice files"
fi fi
# echo "Encoder to use: ${LAME}${OGGENC}${SPEEXENC}(${DEFAULT_CHOICE})?" # echo "Encoder to use: ${LAME}${OGGENC}${SPEEXENC}(${DEFAULT_CHOICE})?"
# echo "" # echo ""
# echo "Note: Use Lame - the other options won't work" # echo "Note: Use Lame - the other options won't work"
# option=`input` # option=`input`
# case "$option" in option="l"
# [Oo]) case "$option" in
# ENCODER="oggenc" [Oo])
# ENC_OPTS=$VORBIS_OPTS ENCODER="oggenc"
# ;; ENC_OPTS=$VORBIS_OPTS
# [Ss]) ;;
# ENCODER="speexenc" [Ss])
# ENC_OPTS=$SPEEX_OPTS ENCODER="speexenc"
# ;; ENC_OPTS=$SPEEX_OPTS
# [Ll]) ;;
[Ll])
ENCODER="lame" ENCODER="lame"
ENC_OPTS=$LAME_OPTS ENC_OPTS=$LAME_OPTS
# ;; ;;
# *) *)
# ENCODER=$DEFAULT_ENC ENCODER=$DEFAULT_ENC
# ENC_OPTS=$DEFAULT_ENC_OPTS ENC_OPTS=$DEFAULT_ENC_OPTS
# esac esac
echo "Using $ENCODER for encoding voice clips" echo "Using $ENCODER for encoding voice clips"
# Allow the user to input manual commandline options
printf "Enter $ENCODER options (enter for defaults `echo $ENC_OPTS |sed 's/.*=//'`): "
USER_ENC_OPTS=`input`
if [ -n "$USER_ENC_OPTS" ]; then
ENC_OPTS="`echo $ENC_OPTS | sed 's/=.*//'`=\"$USER_ENC_OPTS\""
fi
TEMPDIR="${pwd}" TEMPDIR="${pwd}"
if [ "`which cygpath`" != "" ]; then if [ "`which cygpath`" != "" ]; then
TEMPDIR=`cygpath . -a -w` TEMPDIR=`cygpath . -a -w`
fi fi
cat > voicesettings.sh <<EOF cat > voicesettings-$thislang.sh <<EOF
TTS_ENGINE="${TTS_ENGINE}" TTS_ENGINE="${TTS_ENGINE}"
ENCODER="${ENCODER}" ENCODER="${ENCODER}"
TEMPDIR="$TEMPDIR" TEMPDIR="$TEMPDIR"
@ -456,18 +491,26 @@ picklang() {
done done
read pick read pick
return $pick;
} }
whichlang() { whichlang() {
num=1 output=""
for one in $langs; do # Allow the user to pass a comma-separated list of langauges
if [ "$num" = "$pick" ]; then for thispick in `echo $pick | sed 's/,/ /g'`; do
echo $one num=1
return for one in $langs; do
fi # Accept both the language number and name
num=`expr $num + 1` if [ "$num" = "$thispick" ] || [ "$thispick" = "$one" ]; then
if [ "$output" = "" ]; then
output=$one
else
output=$output,$one
fi
fi
num=`expr $num + 1`
done
done done
echo $output
} }
opt=$1 opt=$1
@ -1429,20 +1472,6 @@ echo "Using source code root directory: $rootdir"
# this was once possible to change at build-time, but no more: # this was once possible to change at build-time, but no more:
language="english" language="english"
# Ask about language if building voice
if [ "yes" = "$voice" ]; then
echo "Select a number for the language to use (default is english)"
picklang
voicelanguage=`whichlang`
if [ -z "$voicelanguage" ]; then
# pick a default
voicelanguage="english"
fi
echo "Voice language set to $voicelanguage"
fi
uname=`uname` uname=`uname`
if [ "yes" = "$simulator" ]; then if [ "yes" = "$simulator" ]; then
@ -1593,7 +1622,7 @@ sed > Makefile \
-e "s,@MANUFACTURER@,${t_manufacturer},g" \ -e "s,@MANUFACTURER@,${t_manufacturer},g" \
-e "s,@ARCHOS@,${archos},g" \ -e "s,@ARCHOS@,${archos},g" \
-e "s,@LANGUAGE@,${language},g" \ -e "s,@LANGUAGE@,${language},g" \
-e "s,@VOICELANGUAGE@,${voicelanguage},g" \ -e "s:@VOICELANGUAGE@:${voicelanguage}:g" \
-e "s,@PWD@,${pwd},g" \ -e "s,@PWD@,${pwd},g" \
-e "s,@CC@,${CC},g" \ -e "s,@CC@,${CC},g" \
-e "s,@LD@,${LD},g" \ -e "s,@LD@,${LD},g" \
@ -1794,6 +1823,9 @@ manual-ztxt:
manual-zip: manual-zip:
\$(SILENT)\$(MAKE) -C \$(MANUALDIR) OBJDIR=\$(BUILDDIR)/manual manual-zip \$(SILENT)\$(MAKE) -C \$(MANUALDIR) OBJDIR=\$(BUILDDIR)/manual manual-zip
features:
\$(SILENT)\$(MAKE) -C \$(APPSDIR) OBJDIR=\$(BUILDDIR)/@APPS@ features
help: help:
@echo "A few helpful make targets" @echo "A few helpful make targets"
@echo "" @echo ""
@ -1832,10 +1864,9 @@ if [ "yes" = "$voice" ]; then
cat >> Makefile <<EOF cat >> Makefile <<EOF
voice: tools voice: tools features
\$(SILENT)\$(MAKE) -C \$(APPSDIR) OBJDIR=\$(BUILDDIR)/@APPS@ features
\$(SILENT)for f in \`cat \$(BUILDDIR)/@APPS@/features\`; do feat="\$\$feat:\$\$f" ; done ; \\ \$(SILENT)for f in \`cat \$(BUILDDIR)/@APPS@/features\`; do feat="\$\$feat:\$\$f" ; done ; \\
\$(TOOLSDIR)/genvoice.sh \$(ROOTDIR) \$(VOICELANGUAGE) \$(ARCHOS)\$\$feat \$(TARGET_ID) voicesettings.sh for lang in \`echo \$(VOICELANGUAGE) |sed "s/,/ /g"\`; do \$(TOOLSDIR)/genvoice.sh \$(ROOTDIR) \$\$lang \$(ARCHOS)\$\$feat \$(TARGET_ID) voicesettings-\$\$lang.sh ; done \\
EOF EOF
fi fi

View file

@ -43,14 +43,17 @@ VOICEFONTIDS=voicefontids
TARGET_ID="$4" TARGET_ID="$4"
createvoicefile() { createvoicefile() {
RLANG="$1"
$GENLANG -e=$ENGLISH -o -t=$TARGET $LANG_FILE > $VOICEFONTIDS $GENLANG -e=$ENGLISH -o -t=$TARGET $LANG_FILE > $VOICEFONTIDS
$VOICEFONT "$VOICEFONTIDS" "$TARGET_ID" "$TEMPDIR/" "./$RLANG.voice" $VOICEFONT "$VOICEFONTIDS" "$TARGET_ID" "$TEMPDIR/" "./$RLANG.voice"
rm -f $VIOCEFONTIDS
} }
deletefiles() { deletefiles() {
# XXX: might be unsafe depending on the value of TEMPDIR # XXX: might be unsafe depending on the value of TEMPDIR
rm -f "${TEMPDIR}"/LANG_* rm -f "${TEMPDIR}"/LANG_*
rm -f "${TEMPDIR}"/VOICE_* rm -f "${TEMPDIR}"/VOICE_*
rm -f "${TEMPDIR}"/NOT_USED_*
} }
generateclips() { generateclips() {
@ -76,17 +79,18 @@ generateclips() {
2) 2)
# String # String
STRING=`echo $line |cut -b 8-` STRING=`echo $line |cut -b 8-`
STRING_MD5=`echo $STRING |md5sum|cut -b-32` # xxx: Should the hash include encoder/tts options?
POOL_FILE=${POOL}/`echo "$STRING" |md5sum|cut -b-32`-${RLANG}.mp3
if [ -n "$POOL" ]; then if [ -n "$POOL" ]; then
# we have a common pool of snippets, check that first # we have a common pool of snippets, check that first
# for available mp3 sounds, and if it is available copy # for available mp3 sounds, and if it is available copy
# (symlink!) it over # (symlink!) it over
if [ -f "$POOL/$STRING_MD5.mp3" ]; then if [ -f "$POOL_FILE" ]; then
echo "Re-using $ID from pool" echo "Re-using $ID from pool (${POOL_FILE})"
if [ ! -e "$TEMPDIR/$ID".mp3 ]; then if [ ! -e "$TEMPDIR/$ID".mp3 ]; then
# only do this if not present # only do this if not present
ln -s "$POOL/$STRING_MD5.mp3" "$TEMPDIR/$ID".mp3 ln -sf "$POOL_FILE" "$TEMPDIR/$ID".mp3
fi fi
fi fi
fi fi
@ -97,8 +101,8 @@ generateclips() {
voice "$STRING" "$TEMPDIR/$ID".wav voice "$STRING" "$TEMPDIR/$ID".wav
if [ -n "$POOL" ]; then if [ -n "$POOL" ]; then
# create it in the pool, symlink it back # create it in the pool, symlink it back
encode "$TEMPDIR/$ID".wav "$POOL/$STRING_MD5".mp3 encode "$TEMPDIR/$ID".wav "$POOL_FILE"
ln -s "$POOL/$STRING_MD5.mp3" "$TEMPDIR/$ID".mp3 ln -sf "$POOL_FILE" "$TEMPDIR/$ID".mp3
else else
encode "$TEMPDIR/$ID".wav "$TEMPDIR/$ID".mp3 encode "$TEMPDIR/$ID".wav "$TEMPDIR/$ID".mp3
fi fi
@ -118,6 +122,7 @@ else
echo "Error: $1 is not a Rockbox directory" echo "Error: $1 is not a Rockbox directory"
exit 33 exit 33
fi fi
# Check for valid language
if [ ! -f "$1/apps/lang/$2.lang" ]; then if [ ! -f "$1/apps/lang/$2.lang" ]; then
echo "Error: $2 is not a valid language" echo "Error: $2 is not a valid language"
exit 34 exit 34
@ -125,7 +130,7 @@ else
if [ ! -z "$5" ]; then if [ ! -z "$5" ]; then
if [ -f "$5" ]; then if [ -f "$5" ]; then
# Read settings from file # Read settings from file
source "$5" . "$5"
else else
echo "Error: $5 does not exist" echo "Error: $5 does not exist"
exit 36 exit 36
@ -144,5 +149,5 @@ init_tts
init_encoder init_encoder
generateclips "$1" "$2" "$3" generateclips "$1" "$2" "$3"
stop_tts stop_tts
createvoicefile createvoicefile "$2"
#deletefiles deletefiles

View file

@ -72,7 +72,7 @@ FESTIVAL_HOST=localhost
FESTIVAL_PORT=1314 FESTIVAL_PORT=1314
# where to log the Festival client output # where to log the Festival client output
FESTIVAL_LOG=/dev/null FESTIVAL_LOG=/dev/null
# other options to the festival client # other options to the festival server
FESTIVAL_OPTS="" FESTIVAL_OPTS=""
################## ##################
@ -140,7 +140,7 @@ init_tts() {
exit 3 exit 3
fi fi
FESTIVAL_HOST='localhost' FESTIVAL_HOST='localhost'
$FESTIVAL_BIN --server 2>&1 > /dev/null & $FESTIVAL_BIN $FESTIVAL_OPTS --server 2>&1 > /dev/null &
FESTIVAL_SERVER_PID=$! FESTIVAL_SERVER_PID=$!
sleep 3 sleep 3
if [ `ps | grep -c "^\ *$FESTIVAL_SERVER_PID"` -ne 1 ]; then if [ `ps | grep -c "^\ *$FESTIVAL_SERVER_PID"` -ne 1 ]; then
@ -271,7 +271,7 @@ voice() {
case $TTS_ENGINE in case $TTS_ENGINE in
festival) festival)
echo "Action: Generate $WAV_FILE with festival" echo "Action: Generate $WAV_FILE with festival"
echo -E "$TO_SPEAK" | $FESTIVAL_CLIENT $FESTIVAL_OPTS \ echo -E "$TO_SPEAK" | $FESTIVAL_CLIENT \
--server $FESTIVAL_HOST \ --server $FESTIVAL_HOST \
--otype riff --ttw --output "$WAV_FILE" 2>"$WAV_FILE" --otype riff --ttw --output "$WAV_FILE" 2>"$WAV_FILE"
;; ;;