Tuesday, March 30, 2010

HTK bug of HHEd

Description:
When I run HHEd -T 1 -H lib/am/MMF44 -M classes regtree.hed MMF44.mlist
The output is as follows:
HHEd
65561/18300 Models Loaded [5 states max, 8 mixes max]

LS lib/am/stats.MMF44.S1.en
Loading state occupation stats
Stats loaded for 18300 models
Mean Occupation Count = 6833.864217

RC 32 rtree
Building regression tree with 32 terminals
Creating regression class tree with ident rtree.tree and baseclass rtree.base

^
Error { expected
ERROR [+7230] EdError: item list parse error
FATAL ERROR - Terminating program HHEd


Bug:
I had checked for a long time to locate the problem.
Finally, I found that the last line of the regtree.hed file do not have a "\n" at the end of the line. If I added the "\n", everything is fine.
Thus, I think the HHEd of HTK can't read file without a terminator of the file, such as "\n".

Sunday, March 28, 2010

How to use screen command in Linux

$ screen //创建一个跑着shell的单一窗口
//在这个窗口中,你可以正常跑任何程序
//然后Ctrl+a d退出刚创建的窗口
//screen窗口都不会关闭,会在后台正常运行
//重复这样的步骤,可以建立多个独立的shell窗口

$ screen -ls //可以看所有的screen sessions' id

// screen session不再使用的时候
$ screen -r sessionid //输入exit就可以退出,关掉这个screen session

Thursday, March 11, 2010

How to change the NetBeans default JDK

change /etc/netbeans.conf file:

# Default location of JDK, can be overridden by using –jdkhome:
netbeans_jdkhome=”C:\Program Files\Java\jdk1.6.0_05″

How to change NetBeans Interface language

Adding "--locale en_US" to the *netbeans_default_options* value in file:
/etc/netbeans.conf

Thursday, March 4, 2010

How to read Excel file in Java

1. you need to download org.apache.poi from:
http://poi.apache.org/download.html

2. then you can use the package just downloaded in Java, and of course you need to put the package in your own project

3. The following code showing you the simple procedure to read an Excel file:

//http://poi.apache.org/index.html
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

class sample
{
void readExcelFile(String excelFileName)
{
try
{
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(excelFileName));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = null;
HSSFCell cell = null;

int count_rows; // NO of rows
count_rows = sheet.getPhysicalNumberOfRows();

int count_columns = 0; // NO of columns
int current_columns = 0;

// This trick ensures that we get the data properly even if it
// doesn't start from first few rows
for (int r = 0; r<10 && r < count_rows; r++)
{
row = sheet.getRow(r);
if (row != null)
{
current_columns = row.getPhysicalNumberOfCells();
if (current_columns > count_columns)
count_columns = current_columns;
}
}

for (int r = 0; r < count_rows; r++)
{
row = sheet.getRow(r);
if (row != null)
{// process one row
for (int c = 0; c < count_columns; c++)
{
cell = row.getCell(c);
if (cell != null)
{// main part of processing cells

System.out.print(cell.getStringCellValue()+" ");
}
}
System.out.println();
}
}
}
catch (Exception ioe)
{
ioe.printStackTrace();
}
}
}

Wednesday, February 3, 2010

How to compile HTK under Visual Studio 2008

This post describes how to compile HTK source code under Visual Studio 2008 on Windows.

0. Download HTK source code for Windows from:
http://htk.eng.cam.ac.uk/download.shtml
and decompress it, after which you can get the following folders:


1. Create a solution named "HTK-windows", and also a project named "HCopy" in VS2008:

and then in the configuration of project "HCopy", you need to click on the box of "Empty project" as follows:



2. Configure the project "HCopy"
You first need to copy the HTKLib folder to the root directory of your solution "HTK-windows", and then copy the file "HCopy.c" in the folder "HTKTools" to the root directory of your project "HCopy".

Right click the project "HCopy", and then click the "Properties" as follows:


In the "Properties" window, you need to add the "HTKLib" folder (or $(SolutionDir)\HTKLib) located in the root directory of your solution, to the "Additional Include Directories":


Then add /D "ARCH=WIN32" to the "Command Line":


3. Add the the files (*.c and *.h) except "HGraf.c" and "HGraf.null.c" in folder "HTKLib" into project "HCopy":




4. Finally, you can build your project "HCopy":


5. Of course, here I only present how to compile HCopy of HTK in VS2008, and you can follow more or less the same procedure to compile other tools of HTK. You just need to create new projects under the solution "HTK-windows" as follows:



PS: if you want to build HSLab.c, you need to exclude HFB.h and HFB.c;
if you want to build HDecode.c, you need to add an additional command line parameter /D "NO_LAT_LM", and also do not add HLM.h and HLM.c to your project "HDecode".

Wednesday, January 20, 2010

How to set the locale environment variables under Linux

The locale environment variables can affect the encoding of Java applications.
Thus, sometimes if you do not set the variables correctly, you can't run your Java applications.

You can run command "locale" to display all the locale environment variables of current shell:
$ locale
LANG=en_US.utf8
LC_CTYPE=de_DE.utf8
LC_NUMERIC=de_DE.utf8
LC_TIME=de_DE.utf8
LC_COLLATE=de_DE.utf8
LC_MONETARY=de_DE.utf8
LC_MESSAGES=en_US.utf8
LC_PAPER=de_DE.utf8
LC_NAME=de_DE.utf8
LC_ADDRESS=de_DE.utf8
LC_TELEPHONE=de_DE.utf8
LC_MEASUREMENT=de_DE.utf8
LC_IDENTIFICATION=en_US.utf8
LC_ALL=


You can see all the supported locale settings using:
$locale -a

The setting of LC_CTYPE seems to be decisive over all other variables except for LC_ALL. Setting LC_ALL overrides any other locale variable.