I've been looking at Hidden Markov Model software for my final-year university project, and HTK seems the most promising–but it was a pain to install, so I'd like to save others some time!November 06, 2019 - 10:27:06
Hidden Markov Models are a type of statistical model popular for modelling sequential systems (especially temporal sequences, or time series), but if you're looking to install HTK, you probably already know what they are, right?
What is HTK?
HTK (or Hidden Markov Model Toolkit) is a toolkit developed at the Speech Vision and Robotics Group, University of Cambridge. The tool is most commonly used for modelling speech systems, and therefore has some degree of specialization towards tasks of this nature, but is still frequently used for modeling other types of sequential systems.
Unfortunately, with the software being much older than existing popular Python libraries such as
hmmlearn or R libraries like
depmixS4, this also means that it is a bit more complicated to set up and start working with right away–especially for individuals not familiar with building C programs from source.
The toolkit installation procedure for macOS doesn't seem to work right out of the box due to some issues with C header files.
(1) To start with, you'll need to go to http://htk.eng.cam.ac.uk/ and complete the registration before you can download HTK.
(2) After you've registered, go to the downloads page and download both the source code and samples from the latest Linux/UNIX stable release (3.4.1 at the time this post was published).
While you're here, you may also want to download the documentation book because HTK has a lot of features.
(3) Open up a terminal on your device and move into the source code directory that you just downloaded, and run the provided C configuration script:
./configure --without-x --disable-hslab
If you need HSLab (an interactive editor for manipulating speech label files), then just remove the
As explained on ThoughtBot:
configurescript is responsible for getting ready to build the software on your specific system. It makes sure all of the dependencies for the rest of the build and install process are available, and finds out whatever it needs to know to use those dependencies.
(4) Once the
configurescript has successfully finished running, you'll need to modify the
Find the line (near the top of the file) that includes the
Then change this to:
Direct inclusion of the
mallocheader file has become deprecated as it is not a standard header across different UNIX systems–it often defines additional functions specific to the
mallocimplementation used by the specific platform.
stdlibheader should be used since the standard library contains the standard definition for
mallocand its related standard functions.
(5) Finally, to build and install HTK, run:
make all make install
And that's all! But if you want to test the installation, you can run the demo code provided in the
HTKDemo subdirectory of the samples folder you downloaded from the HTK website.
Before running this, you'll need to create some folders that the demo depends on. These commands should be executed in the
# Create the necessary folders for the demo mkdir proto test hmms/hmm.0 hmms/hmm.1 hmms/hmm.2 # Run the demo program ./runDemo configs/monPlainM1S3.dcf
If this runs successfuly, you're set!