From 58537b43e61b23053371d92e9521e104d0908bca Mon Sep 17 00:00:00 2001 From: Jonas Häggqvist Date: Mon, 13 Aug 2007 12:21:16 +0000 Subject: 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 --- tools/configure | 123 ++++++++++++++++++++++++++++++++------------------- tools/genvoice.sh | 23 ++++++---- tools/voicecommon.sh | 6 +-- 3 files changed, 94 insertions(+), 58 deletions(-) (limited to 'tools') diff --git a/tools/configure b/tools/configure index 3af6885ab0..041c7d3f8d 100755 --- a/tools/configure +++ b/tools/configure @@ -284,8 +284,25 @@ whichadvanced () { echo "done" 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 if [ "yes" = "$use_debug" ]; then debug="-DDEBUG" @@ -304,8 +321,10 @@ whichadvanced () { fi } +# Configure voice settings voiceconfig () { - echo "Building voice for $archos" + thislang=$1 + echo "Building $thislang voice for $archos. Select options" echo "" if [ "`which flite`" != "" ]; then @@ -377,6 +396,13 @@ voiceconfig () { esac 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 "" if [ "`which oggenc`" != "" ]; then @@ -402,37 +428,46 @@ voiceconfig () { fi 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 # echo "Encoder to use: ${LAME}${OGGENC}${SPEEXENC}(${DEFAULT_CHOICE})?" # echo "" # echo "Note: Use Lame - the other options won't work" # option=`input` -# case "$option" in -# [Oo]) -# ENCODER="oggenc" -# ENC_OPTS=$VORBIS_OPTS -# ;; -# [Ss]) -# ENCODER="speexenc" -# ENC_OPTS=$SPEEX_OPTS -# ;; -# [Ll]) + option="l" + case "$option" in + [Oo]) + ENCODER="oggenc" + ENC_OPTS=$VORBIS_OPTS + ;; + [Ss]) + ENCODER="speexenc" + ENC_OPTS=$SPEEX_OPTS + ;; + [Ll]) ENCODER="lame" ENC_OPTS=$LAME_OPTS -# ;; -# *) -# ENCODER=$DEFAULT_ENC -# ENC_OPTS=$DEFAULT_ENC_OPTS -# esac + ;; + *) + ENCODER=$DEFAULT_ENC + ENC_OPTS=$DEFAULT_ENC_OPTS + esac 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}" if [ "`which cygpath`" != "" ]; then TEMPDIR=`cygpath . -a -w` fi - cat > voicesettings.sh < voicesettings-$thislang.sh < Makefile \ -e "s,@MANUFACTURER@,${t_manufacturer},g" \ -e "s,@ARCHOS@,${archos},g" \ -e "s,@LANGUAGE@,${language},g" \ - -e "s,@VOICELANGUAGE@,${voicelanguage},g" \ + -e "s:@VOICELANGUAGE@:${voicelanguage}:g" \ -e "s,@PWD@,${pwd},g" \ -e "s,@CC@,${CC},g" \ -e "s,@LD@,${LD},g" \ @@ -1794,6 +1823,9 @@ manual-ztxt: manual-zip: \$(SILENT)\$(MAKE) -C \$(MANUALDIR) OBJDIR=\$(BUILDDIR)/manual manual-zip +features: + \$(SILENT)\$(MAKE) -C \$(APPSDIR) OBJDIR=\$(BUILDDIR)/@APPS@ features + help: @echo "A few helpful make targets" @echo "" @@ -1832,10 +1864,9 @@ if [ "yes" = "$voice" ]; then cat >> Makefile < $VOICEFONTIDS $VOICEFONT "$VOICEFONTIDS" "$TARGET_ID" "$TEMPDIR/" "./$RLANG.voice" + rm -f $VIOCEFONTIDS } deletefiles() { # XXX: might be unsafe depending on the value of TEMPDIR rm -f "${TEMPDIR}"/LANG_* rm -f "${TEMPDIR}"/VOICE_* + rm -f "${TEMPDIR}"/NOT_USED_* } generateclips() { @@ -76,17 +79,18 @@ generateclips() { 2) # String 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 # we have a common pool of snippets, check that first # for available mp3 sounds, and if it is available copy # (symlink!) it over - if [ -f "$POOL/$STRING_MD5.mp3" ]; then - echo "Re-using $ID from pool" + if [ -f "$POOL_FILE" ]; then + echo "Re-using $ID from pool (${POOL_FILE})" if [ ! -e "$TEMPDIR/$ID".mp3 ]; then # 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 @@ -97,8 +101,8 @@ generateclips() { voice "$STRING" "$TEMPDIR/$ID".wav if [ -n "$POOL" ]; then # create it in the pool, symlink it back - encode "$TEMPDIR/$ID".wav "$POOL/$STRING_MD5".mp3 - ln -s "$POOL/$STRING_MD5.mp3" "$TEMPDIR/$ID".mp3 + encode "$TEMPDIR/$ID".wav "$POOL_FILE" + ln -sf "$POOL_FILE" "$TEMPDIR/$ID".mp3 else encode "$TEMPDIR/$ID".wav "$TEMPDIR/$ID".mp3 fi @@ -118,6 +122,7 @@ else echo "Error: $1 is not a Rockbox directory" exit 33 fi + # Check for valid language if [ ! -f "$1/apps/lang/$2.lang" ]; then echo "Error: $2 is not a valid language" exit 34 @@ -125,7 +130,7 @@ else if [ ! -z "$5" ]; then if [ -f "$5" ]; then # Read settings from file - source "$5" + . "$5" else echo "Error: $5 does not exist" exit 36 @@ -144,5 +149,5 @@ init_tts init_encoder generateclips "$1" "$2" "$3" stop_tts -createvoicefile -#deletefiles +createvoicefile "$2" +deletefiles diff --git a/tools/voicecommon.sh b/tools/voicecommon.sh index e18308ee4e..61e0d07bdd 100644 --- a/tools/voicecommon.sh +++ b/tools/voicecommon.sh @@ -72,7 +72,7 @@ FESTIVAL_HOST=localhost FESTIVAL_PORT=1314 # where to log the Festival client output FESTIVAL_LOG=/dev/null -# other options to the festival client +# other options to the festival server FESTIVAL_OPTS="" ################## @@ -140,7 +140,7 @@ init_tts() { exit 3 fi FESTIVAL_HOST='localhost' - $FESTIVAL_BIN --server 2>&1 > /dev/null & + $FESTIVAL_BIN $FESTIVAL_OPTS --server 2>&1 > /dev/null & FESTIVAL_SERVER_PID=$! sleep 3 if [ `ps | grep -c "^\ *$FESTIVAL_SERVER_PID"` -ne 1 ]; then @@ -271,7 +271,7 @@ voice() { case $TTS_ENGINE in 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 \ --otype riff --ttw --output "$WAV_FILE" 2>"$WAV_FILE" ;; -- cgit v1.2.3