#!/bin/sh
#
# Script for IViE transcriptions
#
# The IViE script was created by Esther Grabe and is based on the ToBI 
# transcriber script written by David Talkin, Kim Silverman and John Pitrelli.
# The ToBI version depended on xwaves 3.1 (ESPS 4.2) or later.  




# NOTE: this script is for non-interactive speech data only, i.e. the sentences,
the Cinderella passage and the retold version of the passage..



case "$#" in
        0) echo "Usage: $0 basename1 basename2 ... "; exit 1;;
esac

WORDMENU=wordmenu
PROMMENU=prommenu
TARGMENU=targmenu
TONEMENU=tonemenu
MISCMENU=miscmenu


# YOU NEED TO ADAPT THE PATH IN THE FOLLOWING LINE. PLACE ALL
# DOWNLOADED IVIE DATA AND THE SCRIPT IN A SINGLE DIRECTORY, E.G.
# IViE_data. THEN CHECK THE PATH TO THAT DIRECTORY WITH 'PWD' AND
# INSERT THE PATH INTO THE LINE BELOW (i.e. REPLACE /XXX/XXX/XXX/
# AS APPROPRIATE).


TMP=/XXX/XXX/XXX/IVIE_data/label$$

rm -f $TMP

# IF YOU WANT TO CHANGE THE PITCH RANGE THAT IS DISPLAYED BECAUSE YOU
# CAN'T SEE ALL OF THE F0 TRACE, THEN YOU NEED TO CHANGE THE F0 MINIMUM AND THE 
# F0 RANGE SPECIFIED IN THE FOLLOWING LINE AS DESIRED (i.e. f0_min and f0_range).
# The range given below is for female speakers.


echo waves set f0_min 150 f0_range 250 f0_size 1 ref_size 5 colormap greymap > $TMP
echo waves attach function xlabel >> $TMP
echo waves sleep seconds .2 >> $TMP

for NAME in $*
do
  F0=$NAME.f0
  SPEECH=$NAME.wav
  echo waves make name $NAME file $F0 loc_y 500 loc_x 0 height 300 width 1200 >> $TMP

  echo $NAME activate file $F0 num 0 >> $TMP

  echo waves make name $NAME file $SPEECH loc_y 15 loc_x 0 height 135 >> $TMP
 
# loc_y ...: speechwave window location from upper edge of screen -> decrease,
# window moves up. loc_x refers to location from left edge of screen, 
# i.e at the left edge at the moment


  echo waves send make signal $SPEECH name $NAME file $NAME.wds label_height 50 color 115 menufile $WORDMENU >> $TMP
  echo waves sleep seconds .2 >> $TMP

  echo waves send make signal $SPEECH name $NAME file $NAME.pms color 100 menufile $PROMMENU >> $TMP
  echo waves sleep seconds .2 >> $TMP

  echo waves send make signal $SPEECH name $NAME file $NAME.tgs color 100 menufile $TARGMENU  >> $TMP
  echo waves sleep seconds .2 >> $TMP

  echo waves send make signal $SPEECH name $NAME file $NAME.tns menufile $TONEMENU >> $TMP
  echo waves sleep seconds .2 >> $TMP

  echo waves send make signal $SPEECH name $NAME file $NAME.mcs color 115 menufile $MISCMENU >> $TMP
  echo waves sleep seconds .2 >> $TMP
  

  echo $NAME align file $F0 >> $TMP
  echo waves pause >> $TMP
  echo waves kill >> $TMP
  echo waves sleep seconds .2 >> $TMP
done

echo waves quit >> $TMP


xwaves $TMP

rm -f $TMP










