Compiling HTK 3.4 on Windows XP
Introduction
Here are some notes on my experiences of compiling HTK 3.4 on Windows XP. I compiled HTK successfully, but some research and experiment was necessary. In the end I tried and was successful with Cygwin and with Visual Studio Express. I hope you find these notes useful.
The issues addressed here will obtain whether you’re using the makefiles that come bundled in the htk3.4 zipfile or the winmakefiles makefiles refered to by Anna Langley in her 02/02/07 post to htk-users.
These notes do not cover getting HSLab to run on Windows. I hope to look into that in the near future. In the meantime, I recommend Praat for labelling, and Praat or SpeechRecorder for recording.
From now on (22nd March 2008) I shall not approve comments to this post asking about HSLab.
Preparation
Getting the htk source code
Download the HTK source zipfile form the HTK website. Note you must register - and make sure you read the licence! - before you can download either the code or the documentation.
‘Mac’ format
The source files have multiple carriage returns (’\r’) at line ends. This upsets both make (cygwin) and nmake (VSE). Nmake appears to think the files are in Mac format and won’t touch them. I don’t know why this spurious whitespace is there, or why it should cause such problems. In any case, the first step is to strip out these characters from all source files. Write a little script in your favourite language, or use this Python script:
#! /usr/bin/python
import os
def convert(fn):
data = open(fn).read().replace('\r\r', '')
open(fn, 'w').write(data)
def main(dataDir):
for root, dirs, files in os.walk(dataDir):
for fn in files:
fullFn = os.path.join(root, fn)
convert(fullFn)
if __name__ == '__main__':
dataDir = 'HTK-3.4/htk/'
main(dataDir)
Using cygwin
Requirements
You’ll need Cygwin, of course, and make sure you have installed gcc (which might not be included by default).
Prepare HTK source code
The only changes to the source code I found necessary (apart from the line-end changes above), were those pointed out by Mark Huckvale of UCL in his HTK howto.
1. Remove the reference to "-lX11" in the instructions for HSLab:
Change HTKTools/Makefile line 55f
from:
%: %.c $(HTKLIB)
if [ ! -d $(bindir) -a X_ = X_yes ] ; then mkdir -p $(bindir) ; fi
if [ x$@ = xHSLab ] ; then
$(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) -lX11 ;
else
$(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) ; fi</pre>
to:
%: %.c $(HTKLIB)
if [ ! -d $(bindir) -a X_ = X_yes ] ; then mkdir -p $(bindir) ; fi
if [ x$@ = xHSLab ] ; then
$(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) ;
else
$(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) ; fi</pre>
2. Overwrite HGraf.c
$ cd HTKLib $ cp HGraf.c HGraf.c.original $ cp HGraf.null.c HGraf.c $ cd ..</pre>
Compilation
HTK should now compile with ./configure; make; make install as in the README.
To make HTK available from outside cygwin
HTK is now available only from inside cygwin (e.g., from the cygwin terminal). To make HTK available from the rest of Windows you need to put two things on your PATH:
- the path to the HTK bin files (e.g.: C:\cygwin\usr\local\bin);
- the path to the cygwin1.dll (i.e.: C:\cygwin\bin)
Once you’ve put these on your PATH, you should be able to call HTK commands from the Command Prompt window (or anywhere else).
Using visual studio express
Update (27/07/2007): Arlindo Vega has posted to htk-users and created a web page covering compilation of HTK on Windows using Visual Studio 6, 7 (VS.Net2003) and 8 (VS2005).
Set up
Download and install the following (go to the Microsoft VS Express download page and follow the instructions):
- Visual C++ 2005 Express Edition.
- Visual Studio Express Editions 2005 Service Pack 1.
- Microsoft Platform SDK for Microsoft Visual C++ 2005 Express.
n.b.: These are large downloads. Download requires registration.
Make sure the bin/, lib/ & include/ directories of the MS Platform SDK are in your PATH.
Reboot!
Make clean!
Everything should now work as in the README. However, if you get an error message like the following:
C:..htkHTKLib>nmake /f htk_htklib_nt.mkf all <.../> Microsoft (R) Program Maintenance Utility Version 8.00.50727.762 Copyright (C) Microsoft Corporation. All rights reserved. lib /OUT:HTKLib.win32.lib esig_asc.obj esig_edr.obj esignal.obj esig_nat.obj HAdapt.obj HAudio.obj HDict.obj HFB.obj HGraf.null.obj HLabel.obj HLat.obj HLM.obj HMap.obj HMath.obj HMem.obj HModel.obj HNet.obj HParm.obj HRec.obj HShell.obj HSigP.obj HTrain.obj HUtil.obj HVQ.obj HWave.obj strarr.obj HExactMPE.obj HFBLat.obj HArc.obj Microsoft (R) Library Manager Version 8.00.50727.762 Copyright (C) Microsoft Corporation. All rights reserved. esig_asc.obj : fatal error LNK1107: invalid or corrupt file: cannot read at 0x1776 NMAKE : fatal error U1077: '"C:Program FilesMicrosoft Visual Studio 8VCBINlib.EXE"' : return code '0x453' Stop.
Try:
C:pathtohtkHTKLib>nmake /f htk_htklib_nt.mkf clean
And then run your original make again.
Conclusion
HTK will compile on Windows, as long as care is taken over the initial set-up. I hope these notes make that set-up easier.
August 28th, 2007 at 3:41 pm
Hi, could you help me please.
You could send me the source files without the multiple carriage returns (’\r’) at line ends??? Or where i can get the HTK-3.3 version???
Because i followed all the steps but i can’t run the HSLab.exe
When i tried i received the error above:
C:\Toolkit\htk>HSLab genesis.sig
ERROR [+6870] MakeXGraf: Not compiled with X11 support: use HGraf.X.c
FATAL ERROR - Terminating program HSLab
August 28th, 2007 at 4:30 pm
Hi Nelson, thanks for your post.
Your error is not due to the line-ends, it’s because HTK has been compiled without support for X — in fact I get the same error when I try to run HSLab on an audio file. I get the same error whether I use the cygwin or the VSExpress version of HSLab.
I can only think of two things to suggest:
(a) Run it under Linux (which will have X), or;
(b) if you’re running under cygwin, install X in cygwin,
recompile htk without making Mark Huckvale’s changes,
and try again.
Let me know how you get on — especially if you try plan (b)!
December 27th, 2007 at 3:06 pm
Do I need GCC in the case of windows.
What is the corresponding command for ./configure for window XP.
Thank you.
December 28th, 2007 at 10:32 pm
Kasaye:
If you’re compiling within cygwin, use gcc, and you can use ./configure; make; make install - cygwin is a unix environment.
If you’re using VS, that provides the compiler and the nmake command (see above).
Ivan
January 25th, 2008 at 8:57 am
how to use Cygwin to compile HTK?
is there any other alternative?
January 25th, 2008 at 10:13 am
You can also use MS Visual Studio. The article should have a table of contents. Look for the section in the article above ‘Using Visual Studio Express’.
Ivan
February 8th, 2008 at 2:39 pm
hello, how i can install X in cygwin, or exist any other solution for run hslab.exe in windows, without use cygwin
thanks
March 3rd, 2008 at 1:20 pm
hello,it’s the first time i use HTK.
I compile it as what sayes in the README.But it doesn’t metioned about cygwin.Shoud i have to use it?
My english is not so good and i hope you can understand me.
Thank you!
March 4th, 2008 at 10:54 pm
Hi, I did this C:\path\to\htk\HTKLib>nmake /f htk_htklib_nt.mkf clean but the error continues, can someone help me please?
Thank you!!!!
March 5th, 2008 at 11:54 am
Hi, I hope that you can help me;
how can i read waveforms enregistred with praat using htk3.3 version
March 7th, 2008 at 11:11 am
Dear All,
Thanks for your comments.
I’ve reformatted the post slightly, with a table of contents, to make it easier to use.
I haven’t covered getting hslab to run on Windows, which I think is a separate issue. I hope to look into that in the near future. In the meantime, I recommend Praat for labelling, and Praat or SpeechRecorder for recording.
March 12th, 2008 at 1:55 pm
hi,
When I enter this command “nmake /f htk_htklib_nt.mkf all”, I have this error : htk_htklib_nt.mkf : fatal error U1035: ‘expected : or = seperator
So can you please help me
March 12th, 2008 at 2:50 pm
Hi, when i try to record some signal with HTK tool HSLab,
there occurs an error when i push the “rec” button:
$ HSLab blah.sig
ERROR [+6015] StartAudioInput: null audio device
FATAL ERROR - Terminating program HSLab
no idea how to fix this problem…
p.s: i use HTK-3.4 with cygwin
thanks a lot
March 13th, 2008 at 11:49 am
Houssem: Have you removed the extra carriage returns (’\r’s) from line ends? If not, please re-read the section ‘Mac’ Format above.
Nico: Have you read the introduction to the article, where I say, “These notes do not cover getting hslab to run on Windows”?
March 22nd, 2008 at 9:58 am
hi,Ivan.
when i recorded the speech, i received the error just like what the first post said.
C:\Toolkit\htk>HSLab yes01.sig
ERROR [+6870] MakeXGraf: Not compiled with X11 support: use HGraf.X.c
FATAL ERROR - Terminating program HSLab
would you plz show me how to deal with it???
thx.
March 22nd, 2008 at 10:18 am
Eric: read the introduction , where I say, “These notes do not cover getting HSLab to run on Windows, …”.
From now I on shall not approve comments asking about HSLab.
April 12th, 2008 at 1:39 pm
Hi,
could you help me please.
You could send me the source files without the multiple carriage returns (’\r’) at line ends???
When I enter this command “nmake /f htk_htklib_nt.mkf all”, I have this error : htk_htklib_nt.mkf : fatal error U1035: ‘expected : or = seperator
i couldn’t run Python script file for strip out “\r” from all source files.
April 17th, 2008 at 11:03 am
Mahdi
Thanks for your comment.
There was a typo in the convert() function in the script! It should work properly now. Many apologies.
Ivan
May 13th, 2008 at 4:19 am
Hi,
I used the python script to remove the carriage returns… They do get removed but I still continue to get the same error as Mahdi.
Could u please guide?
May 13th, 2008 at 10:35 am
Ravi
If you’ve run the (corrected version of) the script, or otherwise removed the spurious line-endings, then nmake should run fine. Look at which source file is causing your error; look at that file in a text editor; check the line-endings.
If the line-endings are OK, then I can’t explain your error.
Ivan
May 13th, 2008 at 4:16 pm
very sorry to bother again…
If it helps the exact error I get is:
htk_htklib_nt.mkf :fatal error U1035:syntax error:expected ‘:’ or ‘=’ separator
Used the corrected version n checked the source files,make files for the line-endings..there doesnt seem to be a problem in them
May 13th, 2008 at 4:37 pm
the error is
htk_htklib_nt.mkfb6b:(where the b are for angular brackets,didnt get printed above )
August 22nd, 2008 at 1:27 pm
sir will you please help me? sir when i tried to run the HTK Demo, i found that some of the files are missing and they are accs,hmmms,proto and test.will you be able to help me in finding these files… thank you for spending time to read this message