#!/usr/local/bin/perl -w use CGI; use CGI::Carp qw/fatalsToBrowser/; use strict; #configuration and environment variables #path to the environment script my $envScript = "/workspace/mickey0/akantor/pronounce/ifpWeb.env.bash"; ######################### my $query = new CGI; print $query->header; print $query->start_html("Pronounce"); print "
";
print $query->checkbox(-name=>'listIsDict',
-label=>'Treat word list as a pronounciation dictionary.',
#-checked=>'on',
);
print <
END
print $query->h3("Model Type");
print $query->radio_group(
-name=>'modelType',
-Values=>['monophone','triphone'],
-Labels=>{'monophone','Monophone','triphone','Triphone'},
-default=>'triphone');
print $query->blockquote( "Both monophone and triphone models have been trained. The triphone ".
"model almost always gives better results.");
print $query->h3("Forced alignment");
print $query->checkbox(-name=>'noalignment', -label=>'Do not perform forced alignment even if it\'s possible.');
print <
END
#print $query->h3("Word list as dictionary");
print $query->h3("Report Type");
my %outputType=( 'best','Best pronounciation',
'allInfo','All available information (can be read into PERL)',
'errorSum','Accuracy Summary',
'errorReport','Accuracy Summary and report mistakes');
print $query->radio_group(
-name=>'outputType',
-linebreak=>'true',
-Values=>\%outputType,
-default=>'best');
print <
Accuracy summary and report mistakes will also show individual words which were 'mispronounced' as
well as their edit distance.
All available information prints out a perl structure with dictionary, model and forced alignment
definition or as much information as is available. The perl structure can then be read into PERL via
EVAL function.
Best pronounciation simply returns the best possible pronounciation, one word per line.
The query will take a couple of minutes even for a small number of words. Please be patient.
Where can you find English Sparrows? What's your favorite color? ";
# print $query->popup_menu(-name=>'Color',
# -Values=>['black','brown','red','yellow'],
# -default=>'red');
#
# print $query->hidden('Reference','Monty Python and the Holy Grail');
#
# print " What have you got there?
If a pronounciation definition is found in a dictionary, forced alignment
is performed between the string of letters and the sequence of phones.
";
# print $query->checkbox_group(
# -name=>'Sparrow locations',
# -Values=>[England,France,Spain,Asia,Hoboken],
# -linebreak=>'yes',
# -defaults=>[England,Asia]);
#
#
# print "
";
# print $query->scrolling_list(
# -name=>'possessions',
# -Values=>['A Coconut','A Grail','An Icon',
# 'A Sword','A Ticket'],
# -size=>5,
# -multiple=>'true');
#
print $query->submit('action','submit')," ";
print $query->endform;
}
sub do_work {
my($query) = @_;
my(@values,$key);
my %outputType=(
'best' => '0',
'allInfo' => '1',
'errorSum' => '2',
'errorReport' => '3'
);
#print "Here are the current settings in this form
";
#foreach $key ($query->param) {
# print "$key -> ";
# @values = $query->param($key);
# print join(", ",@values),"
\n";
#}
#foreach $key (sort keys %ENV) {
# print "$key=$ENV{$key}
\n";
#}
if($query->param('action')){
print "Query Results
\n";
my $wordlistFname = "queryDir/query.txt";
my $resultsFname = "queryDir/results.txt";
open (WL, ">$wordlistFname") || croak "cannot open >$wordlistFname";
my $wl = $query->param('wordlist');
$wl =~ s/\r//g;
print WL $wl;
close WL;
my $cmd = "cat $wordlistFname | perl -w -S letterToPhone.pl " .
" -m modelDir" .
" -q queryDir/w " .
" -f $wordlistFname " .
" -o $resultsFname " .
" -t " . $query->param('modelType') .
" -v ". $outputType{$query->param('outputType')} .
($query->param('noalignment') ? " --noalignment " : "") .
($query->param('listIsDict') ? " -d $wordlistFname " : "") ;
#print "commandline: $cmd";
my $output = system("bash -c \'source $envScript > /dev/null && $cmd &> /dev/null\'");
print "\n";
print `cat $resultsFname`;
unlink $resultsFname;
print "
\n";
if ($output==0){
print $query->h3('query succeeded');
}
else{
print $query->h3("query failed with error $output.");
}
}
}
sub print_tail {
print <
Back to speech at UIUC.\n
END
;
}