genfeature.tcl - Feature computation script.
genfeature.tcl mlffile [options]
set config(feature,exponent) 0.6 set config(feature,features) 13 set config(feature,filters) 21 set config(feature,framesize) 10.0 set config(feature,windowsize) 16.0 set config(feature,order) 0 set config(feature,preemphasis) 0.98 set config(feature,samplerate) 8000 set config(feature,type) MFCC set config(feature,basedir) /u0/tmp
These values will override the preset default settings. Subsequent
command line options will override the values specified by the
configuration script. Command line parameters are specified using the
param variable.
set param(feature,mlffile) foo
Since command line parameters are typically not optional the user needs to specify the command line parameters as a single "-" character for the settings defined in the configuration script to take effect.
The genfeature.tcl script is used to extract the baseline features for training HMM models. Currently only MFCC/LPC/PLP coefficients are supported. However, the script can easily be modified to include the other processing functions supported by the analysis package.
The default processing may be overrided using the -script switch to specify the user specific code (script). This script must override a function similar to the default GenFeature function. GenFeature accepts as input a string containing the speech waveform filename, the cache name (cdid) and a unique field identifier. The following are the main fields which should be supported. These fields are specified using the Tcl "array set" function.
The user specific script is also used to define the feature post-processing.
When features are loaded for HMM training, only the base features as saved in
the feature cache are used. If further post-processing is required such as
adding the first and second order time derivatives the user needs to specify
the feature processing script via the configuration file. The variable
config(feature,script) is used for this purpose. The user
script needs to provide a function called UserFeat which is
called by the main ComputeFeature function. The code below shows
an example of such a user defined post-processing function.
The following example function shows how one can override the default computation to do Fourier analysis.
package require Analysis package require Mx package require Rtcl package require Wave
proc GenFeature labelfile {
global cacheFile
array set info [lindex $labelfile 0]
set cdid $info(cdid)
set filename $info(filename)
if [info exists info(key)] { set key $info(key) } { set key $filename }
# read wave and compute feature
if ![info exists cacheFile($cdid)] {
set cacheFile($cdid) [obfile open /tmp/$cdid w]
}
if [catch {set wfeat [obfile read $cacheFile($cdid) $key]}] {
puts stderr $filename
set w [wave read $filename]
set fft [analysis realfft initialize]
set wfft [analysis realff $fft $w]
set wspec [analysis pspec $fft $wfft]
obfile write $cacheFile($cdid) $key $wfeat
nuke $w $fft $wfft
}
nuke $wfeat
}
# user post-processing function
proc UserFeat wmf {
# cepstral mean subtraction
set mf [mx zeromean $wmf]
nuke $wmf
# delta
set dd [analysis delta initialize -order 2 -sigmaT2 13]
set mld [analysis delta $dd $mf -flush]; nuke $dd;
lappend mf [set mlc [mx cut $mld :,0:12]]; nuke $mld
# delta^2
set dd [analysis delta initialize -order 2 -sigmaT2 13]
set mld [analysis delta $dd $mlc -flush]; nuke $dd;
lappend mf [mx cut $mld :,0:12]; nuke $mld
set wfeat [mx join col $mf]
nuke $mf
return $wfeat
}
hmminit.tcl, hmmtrain.tcl, hmmembed.tcl, hmmscribe.tcl, hmmsearch.tcl, Master Label File
Johan Schalkwyk
Center for Spoken Language
Understanding
Oregon Graduate Institute of Science &
Technology