Speech synthesis support: Festival

Table of Contents

Configuration
Talking scripts

Talking scripts

by ross at 07:23:57 on October 28, 2011

Create /usr/local/bin/speech-queue:

#!/bin/sh

PATH="/root/bin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin"
QUEUE_DIR="/tmp/speech-queue"


while true; do
    if [ ! -d $QUEUE_DIR ]; then
        mkdir -p $QUEUE_DIR
        chmod a+w $QUEUE_DIR
    fi
    FILES=`ls -t $QUEUE_DIR/`
    for FILE in $FILES; do
        cat $QUEUE_DIR/$FILE | festival --tts
        rm $QUEUE_DIR/$FILE
        sleep 2
    done
    sleep 1
done

And /usr/local/etc/rc.d/speech-queue:

#!/bin/sh

# PROVIDE: speechqueue
# REQUIRE: DAEMON nasd
# BEFORE:  LOGIN

. /etc/rc.subr

name="speechqueue"
rcvar=`set_rcvar`
command="/usr/local/bin/speech-queue"
command_args="&"
command_interpreter="/bin/sh"

load_rc_config $name

: ${speechqueue_enable="NO"}

run_rc_command "$1"

Add to /etc/rc.conf:

speechqueue_enable="YES"
# /usr/local/bin/etc/rc.d/speech-queue start

Now your scripts, for example, conky weather and mail subscripts can place text in /tmp/speech-queue/$RANDOM_NAME. Contents of each file will be rendered as speech, the file is deleted after that. The idea is that your scripts won't talk at the same time.

 

Comments