Click here to register.

Speech Recognition Engines

HTK files from Java problem.
User: iloes
Date: 12/17/2010 5:49 pm
Views: 5953
Rating: 23


I am making a Java application that uses HTK recognition.

I need Java to create feature files in HTK format from
certain data that the program handles. So, I need from
Java to create new files and add data to them. I have
a MatLab function that does this I want:

function escribeHTK(file,d,fp,tc)

fid = fopen(file,'w','b');
[nf,nv] = size(d);
fwrite(fid,nf,'long');              % write frame count
fwrite(fid,round(fp*1.E7),'long');  % write frame period (in 100 ns units)
nby = nv * 4;
fwrite(fid,nby,'short');            % write byte count
fwrite(fid,tc,'short');             % write type code
fwrite(fid,d.','float');            % write data array

But I need to do that in Java. The function above generates
a file whose data format is IEEE754 floating-point big-endian.
Then, the function adds a header and append the features, where
every variable has its own precission.

I have tried to deploy the function above in Java defining
every variable correspondingly (short, long...) and after,
writing in an output stream the header and features using
the method "floatToIntBits" from "Float" class. This
did not work because HTk does not recognize the resulting files
(as if the file does not have the correct format).

I do not want to use MatLab Builder JA so, what can I do?
Anybody knows how can I deploy it?

Thanks a lot.


--- (Edited on 12/17/2010 5:49 pm [GMT-0600] by iloes) ---

Re: HTK files from Java problem.
User: iloes
Date: 3/2/2011 5:29 am
Views: 158
Rating: 22

Thanks, the problem was solved.

--- (Edited on 3/2/2011 5:29 am [GMT-0600] by iloes) ---

Re: HTK files from Java problem.
User: kmaclean
Date: 3/2/2011 7:36 am
Views: 264
Rating: 23

>Thanks, the problem was solved.

how did you fix your problem?

--- (Edited on 3/2/2011 8:36 am [GMT-0500] by kmaclean) ---

Re: HTK files from Java problem.
User: iloes
Date: 3/6/2011 6:46 am
Views: 194
Rating: 19

I use the next method for JAVA.

Regards ;).

public void generaFichero(double[][] samples, String file, double samplePeriod, int paramKind) throws FileNotFoundException, IOException {
        DataOutputStream out = new DataOutputStream(new FileOutputStream(file));
        int nf = samples.length;
        int nv = samples[0].length;
        out.writeInt((int) (samplePeriod * 1e7));
        out.writeShort(4 * nv);
        for (int n = 0; n < nf; n++) {
            for (int m = 0; m < nv; m++) {
                out.writeFloat((float) samples[n][m]);

--- (Edited on 3/6/2011 6:46 am [GMT-0600] by iloes) ---

Re: HTK files from Java problem.
User: kmaclean
Date: 3/6/2011 8:27 am
Views: 1319
Rating: 20


--- (Edited on 3/6/2011 9:27 am [GMT-0500] by kmaclean) ---

--- (Edited on 3/6/2011 9:30 am [GMT-0500] by kmaclean) ---