Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: creation of _dirname.talk etc. on Linux

creation of _dirname.talk etc. on Linux

From: Christian Mahr <christian.mahr.ulm_at_arcor.de>
Date: 2005-02-01

Dear *

last weekend I tried to create "_dirname.talk" files for the directories (and
also *.mp3.talk files to make rockbox to pronounce directory (and also file
name).

Since I maintain my main mp3 collection on linux (Suse9.2), I needed some
simple solution for unix - not Windows.

With the rpm-packages festival, mpg123 and (of course) lame, I created a
little shells script "mktalk", which is able to create the necessary .talk
files:
- It can descend a tree.
- creates the .talk files either only for directories or for all files.
- it does not create a new .talk file if there exists already one
- It either plays the newly created file or operates quiet

Unfortunately the festival package as I have it can pronounce only in english,
but this is ok for most opportunities.

If somebody is interested: please use with care... no guarantees.
If someody wants to store this in rockbox home page - this is also fine with
me.

Regards
                Christian

PS: it removes []-brackets and converts the ampersand & to "and" for
convenience before speech synthesis.

------------------------------ mktalk ----------------------------------------
#!/bin/sh
#
#
usage()
{
echo "
mktalk (c) v1.1 30.01.2005 C.Mahr

usage:
mktalk [ options ] <filenames>

        creates _FNAME.talk files for mp3-directories (default)
        and *mp3.talk files for .mp3 files

options
        -f force re-creation even if .talk file exists
        -r decend recursive
        -q quiet (dont talk to audio output)
        -m create also .mp3.talk files, not only _direname.talk
        -h print this help

--> requires
         text2wave from festival-1.4.3
        lame
        mpg123
";
exit;
}
#

# scan the options
#
while [ ${1:0:1} = "-" ]
do
        case ${1:1:1} in
        f) FORCE=$1 ;;
        r) RECURSIVE=$1 ;;
        q) QUIET=$1 ;;
        m) MP3=$1 ;;
        h) usage ;;
        *) echo Unknown option "$1"; exit;;
        esac
        shift;
done
#
#
TMP=/tmp/mktalk.$$ # temporary wav file
#
while [ "$1" ] ;
do
        FNAME="$1";
#echo "$FNAME"
        if [ -d "${FNAME}" ] ; # is a directory?
        then
                DEST="${FNAME}/_dirname.talk" # target file name
                
                if [ ! -z "$FORCE" -o ! -e "${DEST}" ] ;
                then
                        echo "creating '${DEST}'"
# delete brackets [] and convert & --> "and", then create .wav from it
                        echo "${FNAME}" |tr -d "\[\]"| sed "s/\\&/and/g"| text2wave -o $TMP
                        lame -t --quiet $TMP "$DEST"
                        rm ${TMP}
                        if [ -z "$QUIET" ] ; then mpg123 -q "${DEST}"; fi
                fi;
                if [ "$RECURSIVE" ];
                then
                        echo "descend ${FNAME}";
                        (cd "$FNAME";mktalk ${FORCE} ${RECURSIVE} ${QUIET} ${MP3} *);
                fi
        else
                if [ ! -z ${MP3} ] ; # shall we use mp3 files?
                then
                        if [ "${FNAME:(-4):4}" = ".mp3" ]
                        then
                                DEST="${FNAME}.talk" # different target fname
                                if [ ! -z "$FORCE" -o ! -e "${DEST}" ] ;
                                then
                                        echo "creating '$DEST'"
# strip off ".mp3" and
# delete brackets [] and convert & --> "and"
                                        echo "${FNAME}"|tr -d "\[\]"|sed "s/\\&/and/g"|sed s/.mp3//g|text2wave -o
$TMP
                                        lame -t --quiet $TMP "$DEST"
                                        rm ${TMP}
                                        if [ -z "$QUIET" ] ; then mpg123 -q "${DEST}"; fi
                                fi;
                        else
                                echo "ignored: '${FNAME}'"
                        fi;
                fi;
        fi;
        shift;
done
#
_______________________________________________
http://cool.haxx.se/mailman/listinfo/rockbox
Received on Tue Feb 1 21:44:43 2005


Page was last modified "Jan 10 2012" The Rockbox Crew
aaa