Home > asr > feaRead.m

feaRead

PURPOSE ^

feaRead: Read the feature file generated by hcopy of HTK

SYNOPSIS ^

function [mfcc, info]=feaRead(feaFile, plotOpt)

DESCRIPTION ^

 feaRead: Read the feature file generated by hcopy of HTK
    Usage: [mfcc, info]=feaRead(feaFile, plotOpt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [mfcc, info]=feaRead(feaFile, plotOpt)
0002 % feaRead: Read the feature file generated by hcopy of HTK
0003 %    Usage: [mfcc, info]=feaRead(feaFile, plotOpt)
0004 
0005 %    Roger Jang, 20050303
0006 
0007 if nargin<1, selfdemo; return; end
0008 if nargin<2, plotOpt=0; end
0009 
0010 fid=fopen(feaFile, 'r');
0011 info.frameNum=fread(fid, 1, 'int32');
0012 info.samplePeriod=fread(fid, 1, 'int32');
0013 info.sampleBytes=fread(fid, 1, 'int16');
0014 info.paramKind=fread(fid, 1, 'int16');
0015 info.feaDim=info.sampleBytes/4;
0016 mfcc0=fread(fid, inf, 'float32');
0017 mfcc=reshape(mfcc0, info.feaDim, length(mfcc0)/info.feaDim);
0018 fclose(fid);
0019 
0020 if plotOpt
0021     mesh(mfcc);
0022     box on; rotate3d on
0023 end
0024 
0025 % ====== Self demo
0026 function selfdemo
0027 feaFile='主人下馬客在船.fea';
0028 [mfcc, info]=feaRead(feaFile, 1);
0029 fprintf('info.frameNum = %d\n', info.frameNum);
0030 fprintf('info.samplePeriod = %d\n', info.samplePeriod);
0031 fprintf('info.sampleBytes = %d\n', info.sampleBytes);
0032 fprintf('info.paramKind = %d\n', info.paramKind);

Generated on Tue 01-Jun-2010 09:50:19 by m2html © 2003