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 offclstitle HTK Installationcolor 0Aset /p choice= 是否開始編譯HTK?[y^|n]: if /i "%choice%"=="y" goto install:endecho 按任意鍵結束... & pause > nul exit:installmkdir bin.win32call VCVARS32 bin.win32call cd HTKLibcall nmake /f htk_htklib_nt.mkf allcall cd..call cd HTKToolscall nmake /f htk_htktools_nt.mkf allcall cd..call cd HLMLibcall nmake /f htk_hlmlib_nt.mkf allcall cd..call cd HLMToolscall nmake /f htk_hlmtools_nt.mkf allcall 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