test.tcl
fs setAccess @/home/islpra0/IslData/featAccess
[CodebookSet cbs fs] read ../step8/codebookSet
[DistribSet dss cbs] read ../step2/distribSet
[PhonesSet ps] read ../step2/phonesSet
[Tags tags] read ../step2/tags
[Tree dst ps:PHONES ps tags dss] read ../step2/distribTree
SenoneSet sns [DistribStream str dss dst] -phones ps:PHONES -tags tags
[TmSet tms] read ../step2/transitionModels
[TopoSet tps sns tms] read ../step2/topologies
[Tree tpt ps:PHONES ps tags tps] read ../step2/topologyTree
[Dictionary diction ps:PHONES tags] read ../step4/convertedDict
fs FMatrix LDAMatrix
fs:LDAMatrix.data bload ../step5/ldaMatrix
[DBase db] open ../step1/db.dat ../step1/db.idx -mode r
AModelSet amo tpt ROOT
cbs load ../step8/codebookWeights
dss load ../step8/distribWeights
tpt configure -padPhone @
dst configure -padPhone @
sns setscoreFct base
PHMMSet phmms tpt [tpt.item(0) configure -name]
LCMSet lcms phmms
RCMSet rcms phmms
SVocab voc diction
[LingKS lm NGramLM] load ../step7/langmod
SVMap svmap voc lm
voc read ../step1/vocab
svmap map base
voc:\$ configure -fTag 1
voc:SIL configure -fTag 1
svmap configure -unkString +UNINTELLIGIBLE+
svmap configure -lz 16 -wordPen -0 -filPen 0
STree stree svmap lcms rcms
LTree ltree stree
SPass spass stree ltree
spass configure -morphBeam 30 -stateBeam 50 -wordBeam 35
spass.glat configure -alphaBeam 200 -topN 150
set lzList {2 4 6 8 16}
set lpList {-128 -4 0 4 128 256 512 1024}
proc recogRate { corr hypo } {
# filter hypo
regsub -all {\\(} \$hypo "" hypo
regsub -all {\\)} \$hypo "" hypo
regsub -all " SIL " \$hypo " " hypo
regsub -all {\\+[^ ]*} \$hypo "" hypo
regsub -all {(\\\$|\{|\\})} \$hypo "" hypo
regsub -all " [ ]+" \$hypo " " hypo
set hypo [string trim \$hypo]
# filter ref
regsub -all {\\(} \$corr "" corr
regsub -all {\\)} \$corr "" corr
regsub -all " SIL " \$corr "" corr
regsub -all {\\+[^ ]*} \$corr "" corr
regsub -all {(\\\$|\\{|\\})} \$corr "" corr
regsub -all " [ ]+" \$corr " " corr
set corr [string trim \$corr]
set ali [align \$corr \$hypo]
set total [llength \$corr]
set fehl [expr [llength [lindex \$ali 2]] + [llength [lindex \$ali 3]] + [llength [lindex \$ali 4]]]
return [expr 100.0 * (1.0 - \${fehl}.0 / \${total}.0)]
}
proc reportRecogRate {} {
global rr lzList lpList
puts -nonewline "lz\\\\lp |"
foreach lp \$lpList { puts -nonewline [format " %4d |" \$lp] }
puts -nonewline "\\n------+"
foreach lp \$lpList { puts -nonewline "------+" } ; puts ""
foreach lz \$lzList {
puts -nonewline [format "%5s" \$lz] ; puts -nonewline " |"
foreach lp \$lpList {
puts -nonewline [format "%6.1f" \$rr(\$lz,\$lp)] ; puts -nonewline "|"
}
puts ""
}
}
proc testOne { utt } {
global rr lzList lpList
set uttinfo [db get \$utt]
makeArray infoArray \$uttinfo
fs eval \$uttinfo
spass run
set hypo [spass.stab trace]
puts "$utt: $hypo"
set hypo [lrange \$hypo 2 end]
puts "recogRate: [recogRate \$infoArray(TEXT) \$hypo]\n"
# Lattice rescoring
spass.glat connect
spass.glat prune -nodeN [expr 100 * [llength [spass.stab trace]]]
set oldLz [svmap configure -lz]
set oldLp [svmap configure -wordPen]
foreach lz \$lzList {
foreach lp \$lpList {
svmap configure -lz \$lz -wordPen \$lp
set hypo [lindex [spass.glat rescore] 0]
set hypo [lrange \$hypo 2 end]
set rr(\$lz,\$lp) [recogRate \$infoArray(TEXT) \$hypo]
}
}
svmap configure -lz \$oldLz -wordPen \$oldLp
reportRecogRate
}
set fp [open testIDs r]
while { [gets \$fp utt] != -1 } {
puts "testing utterance \$utt"
testOne \$utt
}
exit