Monday, March 25, 2013

HTK Tutorial Steps 3 and 4. Am I done now? I think I'm done.

For Step 3, recording the data, I couldn't figure out how to make HSLab use my mic as input, so I used audacity, following that voxforge tutorial again.

For Step 4, I was able to return once again to the HTKBook, but I got the following error:

  ERROR [+6313]  OpenParmChannel: cannot read HTK Header in File /Users/rcantrel/SR/htk/train/wav/sample14.wav
  ERROR [+6313]  OpenAsChannel: OpenParmChannel failed
  ERROR [+6316]  OpenBuffer: OpenAsChannel failed
  ERROR [+1050]  OpenParmFile: Config parameters invalid
 FATAL ERROR - Terminating program HCopy


I ended up having two config files, my main one, config:

    SOURCEFORMAT = WAV
    TRACE = 1
    MICIN = T


(those are tabs that begin each line)

and a second one, hcopy.config:

TARGETKIND = MFCC_0
TARGETRATE = 100000.0
SAVECOMPRESSED = T
SAVEWITHCRC = T
WINDOWSIZE = 250000.0
USEHAMMING = T
PREEMCOEF = 0.97
NUMCHANS = 26
CEPLIFTER = 22
NUMCEPS = 12
ENORMALISE = F


where the configuration values are at the beginning of the line. The important point is that SOURCEFORMAT = WAV in the main config file. Otherwise, it assumes the input files are .htk files. I don't even know what those are, so I'm pretty sure I don't want to use them.

I set the main config file using:

export HCONFIG=/path/to/config

and the final HCopy command was:

HCopy -T 1 -C hcopy.config -S dt.plp.list

HTK Resources:

list of HTK errors

guy blogging his progress through tutorial (just like me!)

Traversing the HTK Tutorial: A Comedy of Errors

1. Create a grammar, which can then be visualize a word network:

Pillar-of-Autumn:SR rcantrel$ HParse gram wdnet
Segmentation fault: 11



Gr.... I verified using trace (-T 1) that it is reading the grammer:

Pillar-of-Autumn:SR rcantrel$ HParse -T 1 gram wdnet2
Creating HParse net from file gram
Generating Lattice with 5 nodes and 4 links
Writing Word Lattice to wdnet2
Segmentation fault: 11


Just to check what happens with an erroneous dictionary, I deleted a semicolon:

Pillar-of-Autumn:SR rcantrel$ HParse -T 1 gram wdnet2
Creating HParse net from file gram
  ERROR [+3130]  PVariable: Variable digit is undefined
 FATAL ERROR - Terminating program HParse


Fine, I decided to move on. (To be clear, that's the short (very short) version of how I decided to move on.)

2. Create the dictionary:

They have a set of steps that I can use to create my wordlist from sentences, but I decided to strip this one down to its essentials. Emotionally, I needed a win, and I was determined to get one. So I created a tiny dictionary:

ONE

I downloaded the beep dictionary. After several trials, realized that I needed to sort the dictionary in dictionary order:

Pillar-of-Autumn:SR rcantrel$ sort -d beep/beep-1.0  > beepsorted3
Pillar-of-Autumn:SR rcantrel$ HDMan -m -w wlist -l glorp test beepsorted3
Pillar-of-Autumn:SR rcantrel$
Okay, that was disturbingly silent...

Sure enough, even though the beep dictionary contained all the words in my wordlist, it couldn't find a single one!

Missing Words
-------------
ONE

Dictionary Usage Statistics
---------------------------
  Dictionary    TotalWords WordsUsed  TotalProns PronsUsed
 beepsorted3         0          0          0          0
        test         0          0          0          0

1 words required, 1 missing


Dictionary test created


At this point, I decided to move on...to brownies. Yummy delicious brownies. Then, while enjoying brownies, I discovered that the beep dictionary format isn't correct. I downloaded voxforge lexicon (Thanks, htk julius tutorial!) and I had my win in the form of a dictionary:

ONE             [ONE]           w ah n sp

Friday, March 22, 2013

Installing HTK on OS X

I already read a blog post about this (Thanks, Patrick O'Keefe!) but my experience was different enough that I decided to briefly post.

I had to do a number of things to the ./configure line. Like POK, I had to add:

-build=i686-apple-macos

and

CFLAGS=-I/usr/include/malloc

I also had to identify my X11 library and headers:

 LDFLAGS=-L/opt/X11/lib CFLAGS=-I/opt/X11/include

Now, for some reason the first time I got it to work, I had multiple CFLAGS arguments and it worked fine:

./configure -build=i686-apple-macos LDFLAGS=-L/opt/X11/lib CFLAGS=-I/opt/X11/include  CFLAGS=-D'ARCH="darwin"' CFLAGS=-I/usr/include/malloc

The second time, however, that failed, and I figured out that I had to consolidate them:

./configure -build=i686-apple-macos LDFLAGS=-L/opt/X11/lib CFLAGS='-I/opt/X11/include -I/usr/include/malloc'

Still haven't figured out why it appeared to work the first time. It's possible I manually edited the makefiles and then forgot, but I really don't think so.

Now, about that D'ARCH="darwin"...

For some reason, everything else was working but HTKLib/HGraf.c was complaining that it contained the variable ARCH which it had never heard of. The installation info on the HTK download site showed that variable being automatically set, but I couldn't get it to work; I actually had to go into HTKLib/HGraf.c and change variable ARCH to string "darwin". Not good to have to do that, but it seemed to get me up and running, so I'm happy as long as I remember how to do it next time...hence this blog post :)

So now I'm back to happily working through the tutorial in HTKBook...oh goodie. My first grammar-related seg fault. :D