3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 # Copyright (c) 2004 Daniel Gudlat
11 # - http://www.rockbox.org/tracker/task/2131
12 # Copyright (c) 2006 Jonas Häggqvist
13 # - This version, only dirwalk and the following comments remains
15 # All files in this archive are subject to the GNU General Public License.
16 # See the file COPYING in the source tree root for full license agreement.
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
21 # Note: You may wish to change some of the settings below.
23 # A script to automatically generate audio clips containing the names of all
24 # folders in a directory tree for use with the "Talkbox" feature available to
25 # users of the Rockbox open source firmware for Archos MP3 players and
26 # recorders as well as several other devices. Talkbox permits the device to
27 # speak the names of the folders as one navigates the directory structure on
28 # the device, thus permitting "eyes-free" use for those for whom the usual
29 # visual navigation is difficult or simply inadvisable.
31 # Audio clips are captured and stored in wave format, then converted into MP3
32 # format by a third party application (lame). If you execute the script,
33 # passing it the top level of your music file hierarchy as an argument while
34 # your device is connected to your PC, then the resulting audio clips will be
35 # generated and stored in the correct location for use with the Talkbox
36 # feature. Alternatively, if you mirror your music folder structure from your
37 # PC to your Archos device, you can just run the script on the PC and then
38 # update the files on your Archos with your usual synchronization routine.
40 # NOTE: If you don't already have them installed, you may obtain the Festival
41 # text to speech system and several voices at:
43 # http://www.cstr.ed.ac.uk/projects/festival.html
44 # http://festvox.org/festival/
46 # The most pleasant freely available Festival voice I know of is the slt_arctic
47 # voice from HST at http://hts.ics.nitech.ac.jp/
50 # - This script generates talk clips for all files, Rockbox only uses talk clips
51 # for music files it seems.
53 # Include voicecommon.sh from the same dir as this script
54 # Any settings from voicecommon can be overridden if added below the following
56 source `dirname $0`'/voicecommon.sh'
62 # which TTS engine to use. Available: festival, flite, espeak
64 # which encoder to use, available: lame, speex, vorbis (only lame will produce
65 # functional voice clips)
67 # whether to overwrite existing mp3 files or only create missing ones (Y/N)
69 # whether, when overwriting mp3 files, also to regenerate all the wav files
71 # whether to remove the intermediary wav files after creating the mp3 files
73 # whether to recurse into subdirectories
75 # whether to strip extensions from filenames
84 # XXX: add any that needs adding
85 for ext
in mp3 ogg flac mpc sid
; do
86 TO_SPEAK
=`echo "$TO_SPEAK" |sed "s/\.$ext//i"`
90 # Walk directory $1, creating talk files if necessary, descend into
91 # subdirecotries if specified
95 # Do not generate talk clip for talk(.wav) files
96 if [ `echo "$i" | grep -c "\.talk$"` -ne 0 ] || \
97 [ `echo "$i" | grep -c "\.talk\.wav$"` -ne 0 ]; then
98 echo "Notice: Skipping file \"$i\""
102 TO_SPEAK
=`basename "$i"`
103 if [ X
$STRIP_EXTENSIONS = XY
]; then
104 strip_extension
"$TO_SPEAK"
109 SAVE_AS
="$i"/_dirname.talk
110 WAV_FILE
="$SAVE_AS".wav
112 # If a talk clip already exists, only generate a new one if
114 if [ ! -f "$SAVE_AS" ] ||
[ X
$OVERWRITE_TALK = XY
]; then
115 voice
"$TO_SPEAK" "$WAV_FILE"
116 encode
"$WAV_FILE" "$SAVE_AS"
119 # Need to be done lastly, or all variables will be dirty
120 if [ X
$RECURSIVE = XY
]; then
126 WAV_FILE
="$SAVE_AS".wav
128 # If a talk clip already exists, only generate a new one if
130 if [ ! -f "$i.talk" ] ||
[ X
$OVERWRITE_TALK != XY
]; then
131 voice
"$TO_SPEAK" "$WAV_FILE"
132 encode
"$WAV_FILE" "$SAVE_AS"
135 # Remove wav file if specified
136 if [ X
$REMOVEWAV = XY
]; then
141 echo "Warning: $1 is not a directory"
147 if [ $# -gt 0 ]; then