summaryrefslogtreecommitdiff
path: root/tools/genvoice.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/genvoice.sh')
-rwxr-xr-xtools/genvoice.sh23
1 files changed, 14 insertions, 9 deletions
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