#!/usr/bin/perl -w

use Cwd;

$version    = "V1.0";

if ($#ARGV+1 != 3)
{   print 
    "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n".
    "                                                   $version, 13/04/05, vst\n".
    "                                                                          \n".
    "Usage:  make_mfcc_list  mfcc_dir  utts_data  outfile                      \n".
    "                                                                          \n".
    "mfcc_dir     directory where the mfccs reside                             \n".
    "utts_data    file containing a list of pairs (\"uttname\" \"text\")       \n".
    "outfile      mfcc file list, absolute path names                          \n".
    "                                                                          \n".
    "Make tha mfcc file list needed by HVite.                                  \n".
    "                                                                          \n".
    "This used to be part of (define (make_initial_phone_labs ...))            \n".
    "in build_unitsel.scm.                                                     \n".
    "                                                                          \n".
    "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
    exit;
}
# ===========================================================================
$mfcc_dir   = $ARGV[0];
$utts_data  = $ARGV[1];
$outfile    = $ARGV[2];
# ===========================================================================
$em = "ERROR in make_mfcc_list: ";

open(IFD , $utts_data) or die "$em cannot open $utts_data for reading\n";
open(OFD , ">".$outfile) or die "$em cannot write to $outfile\n";

chdir $mfcc_dir or die "$em $mfcc_dir: no such directory\n";
$dir = cwd();
print $dir."\n\n";

# ===========================================================================
while(<IFD>)
{
    chop;
    $_ =~ s/^[( ]*//;
    $_ =~ s/ .*//;
    $f = "$dir/$_.mfcc";

    if(! -r $f)  {die "$em $f: no such file\n"};
    print OFD "$f\n";

}
# ===========================================================================
close IFD;
close OFD;
# ===========================================================================
