1、下載HTK源碼並解壓。傳送門:http://htk.eng.cam.ac.uk/download.shtml(HTK source code )
ps:后面的2、4、5三步可以參閱htk\README文件
2、HTK的編譯需要Microsoft Visual Studio,確保本機裝有VS並且環境變量path里面包含vcvars32.bat的路徑。(例如我的路徑是D:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin)
測試添加成功方法:cmd
>vcvars32
顯示:Setting environment for using Microsoft Visual Studio 2010 x86 tools.
tip:如果你的環境變量里面添加的是類似D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools的路徑,用vsvars32命令也行。
3、修改HTKLib\htkHTKLibhtk_htklib_nt.mkf,將HGraf.null.obj改為HGraf_WIN32.obj、HGraf.null.olv改為HGraf_WIN32.olv。
ps:為什么要修改?如果不修改此處,以后在Windows中調用HTK中的HSLab命令時會出錯,顯示:
ERROR [+6870] MakeXGraf: Not compiled with X11 support: use HGraf.X.c
FATAL ERROR - Terminating program HSLab
修正這個錯誤只需要修改上述兩個地方即可。有的文章說還要刪除HTKTools\Makefile.in中的“-lX11” ,我沒有刪除也可修正。
4、編譯HTK。(你可以參閱README文件,或者其他前輩寫的教程,或者使用我寫的批處理)
View Code
@echo off
cls
title HTK Installation
color 0A
set /p choice= 是否開始編譯HTK?[y^|n]:
if /i "%choice%"=="y" goto install
:end
echo 按任意鍵結束... & pause > nul
exit
:install
mkdir bin.win32
call VCVARS32 bin.win32
call cd HTKLib
call nmake /f htk_htklib_nt.mkf all
call cd..
call cd HTKTools
call nmake /f htk_htktools_nt.mkf all
call cd..
call cd HLMLib
call nmake /f htk_hlmlib_nt.mkf all
call cd..
call cd HLMTools
call nmake /f htk_hlmtools_nt.mkf all
call cd..
echo.
goto end
在htk目錄內新建文件,命名為install.bat,將上述代碼粘貼進去,保存,雙擊運行即可。
該步驟會生成文件夾htk\bin.win32,並且將編譯好的文件放在其內,這些.exe就是htk命令了。文件夾內應該包含如下文件:Cluster.exe HBuild.exe HCompV.exe HCopy.exe HDMan.exe HERest.exe HHEd.exe HInit.exe HLEd.exe HList.exe HLMCopy.exe HLRescore.exe HLStats.exe HMMIRest.exe HParse.exe HQuant.exe HRest.exe HResults.exe HSGen.exe HSLab.exe HSmooth.exe HVite.exe LAdapt.exe LBuild.exe LFoF.exe LGCopy.exe LGList.exe LGPrep.exe LLink.exe LMerge.exe LNewMap.exe LNorm.exe LPlex.exe LSubset.exe
5、設置HTK環境變量。將剛才新生成的目錄bin.win32添加到環境變量path內即可。(例如我的是:D:\program\htk\bin.win32)
測試添加成功方法:cmd
>HInit
顯示:
USAGE: HInit [options] hmmFile trainFiles...
Option Default
-e f Set convergence factor epsilon 1.0E-4
-i N Set max iterations to N 20
-l s Set segment label to s none
-m N Set min segments needed 3
-n Update hmm (suppress uniform seg) off
-o fn Store new hmm def in fn (name only) outDir/srcfn
-u mvwt Update m)eans v)ars w)ghts t)rans mvwt
-v f Set minimum variance to f 1.0E-2
-w f set mix wt/disc prob floor to f 0.0
-A Print command line arguments off
-B Save HMMs/transforms as binary off
-C cf Set config file to cf default
-D Display configuration variables off
-F fmt Set source data format to fmt as config
-G fmt Set source label format to fmt as config
-H mmf Load HMM macro file mmf
-I mlf Load master label file mlf
-L dir Set input label (or net) dir current
-M dir Dir to write HMM macro files current
-S f Set script file to f none
-T N Set trace flags to N 0
-V Print version information off
-X ext Set input label (or net) file ext lab
