home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / fest-141.zip / festival / examples / benchmark < prev    next >
Text File  |  1997-02-26  |  2KB  |  87 lines

  1. #!/bin/sh
  2.  
  3. default_libdir="/projects/festival/lib"
  4.  
  5. while true
  6.     do
  7.     case "$1" in
  8.     -f ) festival="${2}"
  9.         shift 2
  10.         ;;
  11.     -l ) libdir="$2"
  12.         shift 2
  13.         ;;
  14.     * ) break;;
  15.     esac
  16. done
  17.  
  18. text=${1-"$HOME/projects/festival/examples/benchmark.text"}
  19.  
  20. for i in . src/main ../src/main $HOME/projects/festival/src/main /cstr/bin
  21.     do
  22.     if [ -n "$festival" ]
  23.         then
  24.         break;
  25.     fi
  26.     if [ -x "$i/festival" ]
  27.         then
  28.         festival="$i/festival"
  29.     fi
  30. done
  31.  
  32. [ -n "$festival" ] ||
  33.     {
  34.     echo "Can't find festival"
  35.     exit 1
  36.     }
  37.  
  38. if [ -z "$libdir" ]
  39.     then
  40.     case $festival in 
  41.     *main/festival )    libdir=`dirname $festival`/../../lib;;
  42.     * ) libdir=$default_libdir;;
  43.     esac
  44. fi
  45.  
  46. echo Using $festival
  47.  
  48. start_flag_file="/tmp/fest_start_$$"
  49. end_flag_file="/tmp/fest_end_$$"
  50. script="/tmp/fest_script_$$"
  51.  
  52. echo -n > $flag_file;
  53.  
  54. cat > $script <<__END__
  55.  
  56. (set! libdir "$libdir/")
  57. (set! lexdir "$default_libdir/dicts/")
  58. (set! voiced_dir "$default_libdir/voices/")
  59.  
  60. (load (string-append libdir "init.scm"))
  61. (if (probe_file (format nil "%s/.festivalrc" (getenv "HOME")))
  62.     (load (format nil "%s/.festivalrc" (getenv "HOME"))))
  63.  
  64.  
  65. (audio_mode 'async)
  66. (set! tts_hooks (list utt.synth))
  67.  
  68. (puts "start...\n" nil)
  69. (fclose (fopen "$start_flag_file" "w"))
  70.  
  71. (tts_file "$text" (quote text))
  72.  
  73. (fclose (fopen "$end_flag_file" "w"))
  74. (puts "...end\n" nil)
  75. (audio_mode 'close)
  76.  
  77. (quit)
  78.  
  79. __END__
  80.  
  81. eval $festival --script $script
  82.  
  83. perl -e 'print "running time = ", (stat($ARGV[1]))[8]-(stat($ARGV[0]))[8], " seconds\n";' $start_flag_file $end_flag_file
  84.  
  85. /bin/rm -f $start_flag_file $end_flag_file $script
  86.     
  87.