#!/bin/bash

set -x

tdata=$1; shift
rec=$1; shift
tc=$1; shift
ti=$1; shift
NP=$1; shift
mfccname=$1; shift
mapname=$1; shift
MetaData=$*

# rm -f $ti; rm -rf $ti
bin/mkscratch.sh $ti
cp -p $rec/* $ti
cp -r -p $tc/ph $ti/ph
ls -l start start/ph
ls -lL start start/ph
ls -l $ti/ph

# mv $tdata $tdata.junk && { ionice -c2 -n7 rm -rf $tdata.junk & }
bin/mkscratch.sh $tdata
cp -p $rec/coding $tdata
# ( cd $tdata; ln -s ../$rec/coding; )

mkdir $tdata/lab $tdata/mfcc
python bin/generate_VY_HERest.py $mfccname $tdata $rec $mapname $MetaData ||
	die.sh "Generate fails" || exit 1
python bin/basename.py .mfcc <$tdata/trainlist > $ti/trainlist
mv $tdata/lab $ti/lab

phones=$(cat $tdata/generated_phones)

p=${ti#tmpE}
bash bin/redo_trainlist.sh $tdata $ti $ti $NP < $ti/trainlist || die.sh "Redo_trainlist.sh fails" || exit 1

(
cd $ti/ph
cat macros $phones > ../acoustics.mmf
)
