#!/bin/sh
#
# file: $JEIDA/src/verify_data/v1.0/verify_data.sh
#
# this shellscript prints the transcription of a file and
# plays the file. it is invoked as follows:
#
#  verify_data *.val
#

# define lcoal constants
#
AUDIO_EXT=".raw";
VAL_EXT=".val"
TRANS_KEY="transcription =";
CHAN_C0_KEY="_c0";
CHAN_C1_KEY="_c1";

# loop over all arguments
#
for arg do

    # grab the basename
    #
    DIR_NAME=`dirname $arg`;
    BSE_NAME=`basename $arg $VAL_EXT`;

    # check for the val file
    #
    VAL_FILE="$arg";
    echo $VAL_FILE":"

    if (test -f $VAL_FILE) then
	TRANS=`grep "$TRANS_KEY" $VAL_FILE`;
	echo "\t" $TRANS;
    else
	echo "\t" "**> cannot find transcription file";
    fi

    # check channel zero
    #
    RAW_FILE="$DIR_NAME""/""$BSE_NAME""$CHAN_C0_KEY""$AUDIO_EXT";

    if (test -f $RAW_FILE) then
	echo "\t" playing $RAW_FILE;
    else
	echo "\t" "**> cannot find $RAW_FILE";
    fi

    naplay -s 16000 -o mono $RAW_FILE 1>/dev/null 2>&1

    # check channel one
    #
#    RAW_FILE="$DIR_NAME""/""$BSE_NAME""$CHAN_C1_KEY""$AUDIO_EXT";
#
#    if (test -f $RAW_FILE) then
#	echo "\t" playing $RAW_FILE;
#    else
#	echo "\t" "**> cannot find $RAW_FILE";
#    fi
#
#    naplay -s 16000 -o mono $RAW_FILE 1>/dev/null 2>&1

    # add a blank line
    #
    echo;

done

# exit gracefully
#
exit 0
