#! /bin/sh
### Project : lfs (pln)
### Version : 6.1
### File : festival_control
### Author : P.L. Nageoire
### Date : Fri Oct 14 17:34:42 2005
### Licence : GPL
######################################################################

festival_bin_dir=/usr/share/festival/bin
festival_err_file=/var/log/festival.err.log
festival_tmp=/tmp/festival

festival_start(){
    /bin/mkdir -p $festival_tmp
    cd $festival_tmp && rm -f *
    $festival_bin_dir/festival_server \
	-l $festival_tmp \
	$festival_bin_dir/festival 2>$festival_err_file &
}

festival_stop(){
    ps -u root | grep "festival"
    fest_proc=`ps -u root |\
                   grep "festival" |\
	           awk 'BEGIN { ORS = " "} {print $1}'`
    fest_audsp_proc=`ps -u root |\
                   grep "audsp" |\
	           awk 'BEGIN { ORS = " "} {print $1}'`
    echo "Killing processes $fest_proc $fest_audsp_proc"
    for x in $fest_proc
      do
      kill -9 $x
    done
    for x in $fest_audsp_proc
      do
      kill -9 $x
    done
}

festival_$1