Compiling HTK 3.4 on Windows XP

Wednesday, 14th October, 2009

[This post is from my old blog, originally posted Monday 30th July 2007. As it is still read, I have moved it here with no revisions]

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 recommend Praat for labelling, and Praat or SpeechRecorder for recording.

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&gt;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:\path\to\htk\HTKLib&gt;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.

Advertisements

9 Responses to “Compiling HTK 3.4 on Windows XP”


  1. […] Compiling HTK 3.4 on Windows XP. Possibly related posts: (automatically generated)Compiling HTK 3.4 on Windows XP Posted by […]

  2. Tony Says:

    Hi, I just downloaded the newest HTK from its website. I got it to compile in VS 2005 no problem. I am “very” new to HTK, I did the test steps to test the installation, and it seems fine so far.

    I am not sure why did you have to go through so many initial setup to get it running. But it’s probably becoz I haven’t really started using it, so don’t know if it’s all compiled properly.

    Anyway, it’s good to have your article, it’s complete and will be helpful to me later!

    Thanks

  3. BK Says:

    I’m having a similar U1077 error when trying to install HTK on my 64-bit Win7 computer:

    C:\htk\HTKLib>nmake /f htk_htklib_nt.mkf all

    Microsoft (R) Program Maintenance Utility Version 8.00.50727.762
    Copyright (C) Microsoft Corporation. All rights reserved.

    cl /nologo /c /ML /W0 /GX /O2 /G5 /Ob2 /D “NDEBUG” /D “WIN32” /D “_WINDO
    WS” /I “.” /D “WIN32_AUDIO” /D ARCH=\”WIN32\” /D “PHNALG” HAdapt.c
    cl : Command line warning D9035 : option ‘GX’ has been deprecated and will be re
    moved in a future release
    cl : Command line warning D9036 : use ‘EHsc’ instead of ‘GX’
    cl : Command line warning D9002 : ignoring unknown option ‘/ML’
    cl : Command line warning D9002 : ignoring unknown option ‘/G5’
    HAdapt.c
    c:\htk\htklib\HShell.h(49) : fatal error C1083: Cannot open include file: ‘Winso
    ck2.h’: No such file or directory
    NMAKE : fatal error U1077: ‘”C:\Program Files (x86)\Microsoft Visual Studio 8\VC
    \BIN\cl.EXE”‘ : return code ‘0x2’
    Stop.

    Does anyone have an idea of what could be causing the problem? I ran the VCVARS file, so that’s not the problem. Thanks in advance!

  4. BK Says:

    Figured it out. The compiler didn’t install correctly with VS Express.

    • Jon Says:

      So how did you solve the problem since I have the same problem and I am stuck. I have the same error message. Did you re install Microsoft Visual studio?.. Thanks for your help.

  5. llaisdy Says:

    Dear BK

    Thanks for posting your problem, and especially the solution!

    Ivan

  6. Babak Says:

    Hi Guys,

    Any body knows how to make HSLab command which shows the interface, works in windows?

    I have installed HTK and it works perfectly but cannot run HSLab to record and … .

    Thanks


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: