#!/bin/sh
#
# $Id: play_ola.in,v 1.1 2004/11/17 21:39:52 guyou Exp $
#
# Cr par Phil's Free le 30/05/2003
#
# Copyright (C) Phil Buch 2003
#
# Contact : biglux@culte.org
#

# Dsignation de la voix utilise ( adapter)
if [ ! "$MBROLA_VOICE" ]
then
  MBROLA_VOICE=/opt/MBROLA/fr4/fr4
fi
if [ ! "$LLIAPHON_NOARCH" ]
then
  LLIAPHON_NOARCH=/usr/share/lliaphon
fi

usage() {
  echo `basename $0` '[-t <time_ratio>] -f <frequency_ratio>] [<fichier_ola> ...]'
  echo `basename $0` '-h'
  echo '  <time_ratio> : multiplier of the basic phonem duration'
  echo '  <frequency_ratio> : multiplier of the basic pitch values'
  echo '  -h : give this small help text'
  echo ' '
  echo "  example : `basename $0` -t 0.65 -f 1.4 my-file.ola"
  exit 255
}

dur=0.6  # basic phonem duration
freq=1.0 # basic pitches

while [ $# -ne 0 ]
do
  case $1 in
    -h) usage
        ;;
    -t) shift
        if [ $# -eq 0 ]
        then
          usage
        else
          dur=$1
        fi
        ;;
    -f) shift
        if [ $# -eq 0 ]
        then
          usage
        else
          freq=$1
        fi
        ;;
    *)  liste="$liste $1"
        ;;
  esac
  shift
done
          
# mode pipe
if [ -z "$liste" ]
then
  mbrola -e -f $freq -t $dur \
         -I $LLIAPHON_NOARCH/initfile.lia \
	 $MBROLA_VOICE - -.au |
         play -t au -
fi

# mode multi-fichiers
for fic in $liste
do
  mbrola -e -f $freq -t $dur \
         -I $LLIAPHON_NOARCH/initfile.lia \
	 $MBROLA_VOICE $fic -.au |
         play -t au -
done

