summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJonas Häggqvist <rasher@rasher.dk>2007-08-13 12:21:16 +0000
committerJonas Häggqvist <rasher@rasher.dk>2007-08-13 12:21:16 +0000
commit58537b43e61b23053371d92e9521e104d0908bca (patch)
tree7cd0a7c5577dfb9a37cf8b0a85dc8a7803536cc5 /tools
parent414ee9fcc5908b4887134f75fd656ae1966a5c65 (diff)
downloadrockbox-58537b43e61b23053371d92e9521e104d0908bca.tar.gz
rockbox-58537b43e61b23053371d92e9521e104d0908bca.zip
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
Diffstat (limited to 'tools')
-rwxr-xr-xtools/configure123
-rwxr-xr-xtools/genvoice.sh23
-rw-r--r--tools/voicecommon.sh6
3 files changed, 94 insertions, 58 deletions
diff --git a/tools/configure b/tools/configure
index 3af6885ab0..041c7d3f8d 100755
--- a/tools/configure
+++ b/tools/configure
@@ -284,8 +284,25 @@ whichadvanced () {
284 echo "done" 284 echo "done"
285 285
286 if [ "yes" = "$voice" ]; then 286 if [ "yes" = "$voice" ]; then
287 voiceconfig 287 toolset="${toolset} voicefont wavtrim"
288 toolset="${toolset} voicefont wavtrim" 288
289 # Ask about languages to build
290 echo "Select a number for the language to use (default is english)"
291 echo "You may enter a comma-separated list of languages to build"
292
293 picklang
294 voicelanguage=`whichlang`
295
296 if [ -z "$voicelanguage" ]; then
297 # pick a default
298 voicelanguage="english"
299 fi
300 echo "Voice language set to $voicelanguage"
301
302 # Configure encoder and TTS engine for each language
303 for thislang in `echo $voicelanguage | sed 's/,/ /g'`; do
304 voiceconfig "$thislang"
305 done
289 fi 306 fi
290 if [ "yes" = "$use_debug" ]; then 307 if [ "yes" = "$use_debug" ]; then
291 debug="-DDEBUG" 308 debug="-DDEBUG"
@@ -304,8 +321,10 @@ whichadvanced () {
304 fi 321 fi
305} 322}
306 323
324# Configure voice settings
307voiceconfig () { 325voiceconfig () {
308 echo "Building voice for $archos" 326 thislang=$1
327 echo "Building $thislang voice for $archos. Select options"
309 echo "" 328 echo ""
310 329
311 if [ "`which flite`" != "" ]; then 330 if [ "`which flite`" != "" ]; then
@@ -377,6 +396,13 @@ voiceconfig () {
377 esac 396 esac
378 echo "Using $TTS_ENGINE for TTS" 397 echo "Using $TTS_ENGINE for TTS"
379 398
399 # Allow the user to input manual commandline options
400 printf "Enter $TTS_ENGINE options (enter for defaults `echo $TTS_OPTS |sed 's/.*=//'`): "
401 USER_TTS_OPTS=`input`
402 if [ -n "$USER_TTS_OPTS" ]; then
403 TTS_OPTS="`echo $TTS_OPTS | sed 's/=.*//'`=\"$USER_TTS_OPTS\""
404 fi
405
380 echo "" 406 echo ""
381 407
382 if [ "`which oggenc`" != "" ]; then 408 if [ "`which oggenc`" != "" ]; then
@@ -402,37 +428,46 @@ voiceconfig () {
402 fi 428 fi
403 429
404 if [ "$LAME" = "" ]; then 430 if [ "$LAME" = "" ]; then
405 echo "You need to have Lame installed to build voice files" 431 echo "You currently need to have Lame installed to build voice files"
406 fi 432 fi
407 433
408# echo "Encoder to use: ${LAME}${OGGENC}${SPEEXENC}(${DEFAULT_CHOICE})?" 434# echo "Encoder to use: ${LAME}${OGGENC}${SPEEXENC}(${DEFAULT_CHOICE})?"
409# echo "" 435# echo ""
410# echo "Note: Use Lame - the other options won't work" 436# echo "Note: Use Lame - the other options won't work"
411# option=`input` 437# option=`input`
412# case "$option" in 438 option="l"
413# [Oo]) 439 case "$option" in
414# ENCODER="oggenc" 440 [Oo])
415# ENC_OPTS=$VORBIS_OPTS 441 ENCODER="oggenc"
416# ;; 442 ENC_OPTS=$VORBIS_OPTS
417# [Ss]) 443 ;;
418# ENCODER="speexenc" 444 [Ss])
419# ENC_OPTS=$SPEEX_OPTS 445 ENCODER="speexenc"
420# ;; 446 ENC_OPTS=$SPEEX_OPTS
421# [Ll]) 447 ;;
448 [Ll])
422 ENCODER="lame" 449 ENCODER="lame"
423 ENC_OPTS=$LAME_OPTS 450 ENC_OPTS=$LAME_OPTS
424# ;; 451 ;;
425# *) 452 *)
426# ENCODER=$DEFAULT_ENC 453 ENCODER=$DEFAULT_ENC
427# ENC_OPTS=$DEFAULT_ENC_OPTS 454 ENC_OPTS=$DEFAULT_ENC_OPTS
428# esac 455 esac
429 echo "Using $ENCODER for encoding voice clips" 456 echo "Using $ENCODER for encoding voice clips"
457
458 # Allow the user to input manual commandline options
459 printf "Enter $ENCODER options (enter for defaults `echo $ENC_OPTS |sed 's/.*=//'`): "
460 USER_ENC_OPTS=`input`
461 if [ -n "$USER_ENC_OPTS" ]; then
462 ENC_OPTS="`echo $ENC_OPTS | sed 's/=.*//'`=\"$USER_ENC_OPTS\""
463 fi
464
430 TEMPDIR="${pwd}" 465 TEMPDIR="${pwd}"
431 if [ "`which cygpath`" != "" ]; then 466 if [ "`which cygpath`" != "" ]; then
432 TEMPDIR=`cygpath . -a -w` 467 TEMPDIR=`cygpath . -a -w`
433 fi 468 fi
434 469
435 cat > voicesettings.sh <<EOF 470 cat > voicesettings-$thislang.sh <<EOF
436TTS_ENGINE="${TTS_ENGINE}" 471TTS_ENGINE="${TTS_ENGINE}"
437ENCODER="${ENCODER}" 472ENCODER="${ENCODER}"
438TEMPDIR="$TEMPDIR" 473TEMPDIR="$TEMPDIR"
@@ -456,18 +491,26 @@ picklang() {
456 done 491 done
457 492
458 read pick 493 read pick
459 return $pick;
460} 494}
461 495
462whichlang() { 496whichlang() {
463 num=1 497 output=""
464 for one in $langs; do 498 # Allow the user to pass a comma-separated list of langauges
465 if [ "$num" = "$pick" ]; then 499 for thispick in `echo $pick | sed 's/,/ /g'`; do
466 echo $one 500 num=1
467 return 501 for one in $langs; do
468 fi 502 # Accept both the language number and name
469 num=`expr $num + 1` 503 if [ "$num" = "$thispick" ] || [ "$thispick" = "$one" ]; then
504 if [ "$output" = "" ]; then
505 output=$one
506 else
507 output=$output,$one
508 fi
509 fi
510 num=`expr $num + 1`
511 done
470 done 512 done
513 echo $output
471} 514}
472 515
473opt=$1 516opt=$1
@@ -1429,20 +1472,6 @@ echo "Using source code root directory: $rootdir"
1429# this was once possible to change at build-time, but no more: 1472# this was once possible to change at build-time, but no more:
1430language="english" 1473language="english"
1431 1474
1432# Ask about language if building voice
1433if [ "yes" = "$voice" ]; then
1434 echo "Select a number for the language to use (default is english)"
1435
1436 picklang
1437 voicelanguage=`whichlang`
1438
1439 if [ -z "$voicelanguage" ]; then
1440 # pick a default
1441 voicelanguage="english"
1442 fi
1443 echo "Voice language set to $voicelanguage"
1444fi
1445
1446uname=`uname` 1475uname=`uname`
1447 1476
1448if [ "yes" = "$simulator" ]; then 1477if [ "yes" = "$simulator" ]; then
@@ -1593,7 +1622,7 @@ sed > Makefile \
1593 -e "s,@MANUFACTURER@,${t_manufacturer},g" \ 1622 -e "s,@MANUFACTURER@,${t_manufacturer},g" \
1594 -e "s,@ARCHOS@,${archos},g" \ 1623 -e "s,@ARCHOS@,${archos},g" \
1595 -e "s,@LANGUAGE@,${language},g" \ 1624 -e "s,@LANGUAGE@,${language},g" \
1596 -e "s,@VOICELANGUAGE@,${voicelanguage},g" \ 1625 -e "s:@VOICELANGUAGE@:${voicelanguage}:g" \
1597 -e "s,@PWD@,${pwd},g" \ 1626 -e "s,@PWD@,${pwd},g" \
1598 -e "s,@CC@,${CC},g" \ 1627 -e "s,@CC@,${CC},g" \
1599 -e "s,@LD@,${LD},g" \ 1628 -e "s,@LD@,${LD},g" \
@@ -1794,6 +1823,9 @@ manual-ztxt:
1794manual-zip: 1823manual-zip:
1795 \$(SILENT)\$(MAKE) -C \$(MANUALDIR) OBJDIR=\$(BUILDDIR)/manual manual-zip 1824 \$(SILENT)\$(MAKE) -C \$(MANUALDIR) OBJDIR=\$(BUILDDIR)/manual manual-zip
1796 1825
1826features:
1827 \$(SILENT)\$(MAKE) -C \$(APPSDIR) OBJDIR=\$(BUILDDIR)/@APPS@ features
1828
1797help: 1829help:
1798 @echo "A few helpful make targets" 1830 @echo "A few helpful make targets"
1799 @echo "" 1831 @echo ""
@@ -1832,10 +1864,9 @@ if [ "yes" = "$voice" ]; then
1832 1864
1833 cat >> Makefile <<EOF 1865 cat >> Makefile <<EOF
1834 1866
1835voice: tools 1867voice: tools features
1836 \$(SILENT)\$(MAKE) -C \$(APPSDIR) OBJDIR=\$(BUILDDIR)/@APPS@ features
1837 \$(SILENT)for f in \`cat \$(BUILDDIR)/@APPS@/features\`; do feat="\$\$feat:\$\$f" ; done ; \\ 1868 \$(SILENT)for f in \`cat \$(BUILDDIR)/@APPS@/features\`; do feat="\$\$feat:\$\$f" ; done ; \\
1838 \$(TOOLSDIR)/genvoice.sh \$(ROOTDIR) \$(VOICELANGUAGE) \$(ARCHOS)\$\$feat \$(TARGET_ID) voicesettings.sh 1869 for lang in \`echo \$(VOICELANGUAGE) |sed "s/,/ /g"\`; do \$(TOOLSDIR)/genvoice.sh \$(ROOTDIR) \$\$lang \$(ARCHOS)\$\$feat \$(TARGET_ID) voicesettings-\$\$lang.sh ; done \\
1839EOF 1870EOF
1840 1871
1841fi 1872fi
diff --git a/tools/genvoice.sh b/tools/genvoice.sh
index 73b005f697..ec457fb37c 100755
--- a/tools/genvoice.sh
+++ b/tools/genvoice.sh
@@ -43,14 +43,17 @@ VOICEFONTIDS=voicefontids
43 43
44TARGET_ID="$4" 44TARGET_ID="$4"
45createvoicefile() { 45createvoicefile() {
46 RLANG="$1"
46 $GENLANG -e=$ENGLISH -o -t=$TARGET $LANG_FILE > $VOICEFONTIDS 47 $GENLANG -e=$ENGLISH -o -t=$TARGET $LANG_FILE > $VOICEFONTIDS
47 $VOICEFONT "$VOICEFONTIDS" "$TARGET_ID" "$TEMPDIR/" "./$RLANG.voice" 48 $VOICEFONT "$VOICEFONTIDS" "$TARGET_ID" "$TEMPDIR/" "./$RLANG.voice"
49 rm -f $VIOCEFONTIDS
48} 50}
49 51
50deletefiles() { 52deletefiles() {
51 # XXX: might be unsafe depending on the value of TEMPDIR 53 # XXX: might be unsafe depending on the value of TEMPDIR
52 rm -f "${TEMPDIR}"/LANG_* 54 rm -f "${TEMPDIR}"/LANG_*
53 rm -f "${TEMPDIR}"/VOICE_* 55 rm -f "${TEMPDIR}"/VOICE_*
56 rm -f "${TEMPDIR}"/NOT_USED_*
54} 57}
55 58
56generateclips() { 59generateclips() {
@@ -76,17 +79,18 @@ generateclips() {
76 2) 79 2)
77 # String 80 # String
78 STRING=`echo $line |cut -b 8-` 81 STRING=`echo $line |cut -b 8-`
79 STRING_MD5=`echo $STRING |md5sum|cut -b-32` 82 # xxx: Should the hash include encoder/tts options?
83 POOL_FILE=${POOL}/`echo "$STRING" |md5sum|cut -b-32`-${RLANG}.mp3
80 84
81 if [ -n "$POOL" ]; then 85 if [ -n "$POOL" ]; then
82 # we have a common pool of snippets, check that first 86 # we have a common pool of snippets, check that first
83 # for available mp3 sounds, and if it is available copy 87 # for available mp3 sounds, and if it is available copy
84 # (symlink!) it over 88 # (symlink!) it over
85 if [ -f "$POOL/$STRING_MD5.mp3" ]; then 89 if [ -f "$POOL_FILE" ]; then
86 echo "Re-using $ID from pool" 90 echo "Re-using $ID from pool (${POOL_FILE})"
87 if [ ! -e "$TEMPDIR/$ID".mp3 ]; then 91 if [ ! -e "$TEMPDIR/$ID".mp3 ]; then
88 # only do this if not present 92 # only do this if not present
89 ln -s "$POOL/$STRING_MD5.mp3" "$TEMPDIR/$ID".mp3 93 ln -sf "$POOL_FILE" "$TEMPDIR/$ID".mp3
90 fi 94 fi
91 fi 95 fi
92 fi 96 fi
@@ -97,8 +101,8 @@ generateclips() {
97 voice "$STRING" "$TEMPDIR/$ID".wav 101 voice "$STRING" "$TEMPDIR/$ID".wav
98 if [ -n "$POOL" ]; then 102 if [ -n "$POOL" ]; then
99 # create it in the pool, symlink it back 103 # create it in the pool, symlink it back
100 encode "$TEMPDIR/$ID".wav "$POOL/$STRING_MD5".mp3 104 encode "$TEMPDIR/$ID".wav "$POOL_FILE"
101 ln -s "$POOL/$STRING_MD5.mp3" "$TEMPDIR/$ID".mp3 105 ln -sf "$POOL_FILE" "$TEMPDIR/$ID".mp3
102 else 106 else
103 encode "$TEMPDIR/$ID".wav "$TEMPDIR/$ID".mp3 107 encode "$TEMPDIR/$ID".wav "$TEMPDIR/$ID".mp3
104 fi 108 fi
@@ -118,6 +122,7 @@ else
118 echo "Error: $1 is not a Rockbox directory" 122 echo "Error: $1 is not a Rockbox directory"
119 exit 33 123 exit 33
120 fi 124 fi
125 # Check for valid language
121 if [ ! -f "$1/apps/lang/$2.lang" ]; then 126 if [ ! -f "$1/apps/lang/$2.lang" ]; then
122 echo "Error: $2 is not a valid language" 127 echo "Error: $2 is not a valid language"
123 exit 34 128 exit 34
@@ -125,7 +130,7 @@ else
125 if [ ! -z "$5" ]; then 130 if [ ! -z "$5" ]; then
126 if [ -f "$5" ]; then 131 if [ -f "$5" ]; then
127 # Read settings from file 132 # Read settings from file
128 source "$5" 133 . "$5"
129 else 134 else
130 echo "Error: $5 does not exist" 135 echo "Error: $5 does not exist"
131 exit 36 136 exit 36
@@ -144,5 +149,5 @@ init_tts
144init_encoder 149init_encoder
145generateclips "$1" "$2" "$3" 150generateclips "$1" "$2" "$3"
146stop_tts 151stop_tts
147createvoicefile 152createvoicefile "$2"
148#deletefiles 153deletefiles
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
72FESTIVAL_PORT=1314 72FESTIVAL_PORT=1314
73# where to log the Festival client output 73# where to log the Festival client output
74FESTIVAL_LOG=/dev/null 74FESTIVAL_LOG=/dev/null
75# other options to the festival client 75# other options to the festival server
76FESTIVAL_OPTS="" 76FESTIVAL_OPTS=""
77 77
78################## 78##################
@@ -140,7 +140,7 @@ init_tts() {
140 exit 3 140 exit 3
141 fi 141 fi
142 FESTIVAL_HOST='localhost' 142 FESTIVAL_HOST='localhost'
143 $FESTIVAL_BIN --server 2>&1 > /dev/null & 143 $FESTIVAL_BIN $FESTIVAL_OPTS --server 2>&1 > /dev/null &
144 FESTIVAL_SERVER_PID=$! 144 FESTIVAL_SERVER_PID=$!
145 sleep 3 145 sleep 3
146 if [ `ps | grep -c "^\ *$FESTIVAL_SERVER_PID"` -ne 1 ]; then 146 if [ `ps | grep -c "^\ *$FESTIVAL_SERVER_PID"` -ne 1 ]; then
@@ -271,7 +271,7 @@ voice() {
271 case $TTS_ENGINE in 271 case $TTS_ENGINE in
272 festival) 272 festival)
273 echo "Action: Generate $WAV_FILE with festival" 273 echo "Action: Generate $WAV_FILE with festival"
274 echo -E "$TO_SPEAK" | $FESTIVAL_CLIENT $FESTIVAL_OPTS \ 274 echo -E "$TO_SPEAK" | $FESTIVAL_CLIENT \
275 --server $FESTIVAL_HOST \ 275 --server $FESTIVAL_HOST \
276 --otype riff --ttw --output "$WAV_FILE" 2>"$WAV_FILE" 276 --otype riff --ttw --output "$WAV_FILE" 2>"$WAV_FILE"
277 ;; 277 ;;