首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在matlab中读取HTK二进制文件

在matlab中读取HTK二进制文件
EN

Stack Overflow用户
提问于 2015-02-27 09:15:56
回答 1查看 1.8K关注 0票数 3

我运行HTK包从我的数据中提取MFCC特性。但是现在这个特性被存储在.mfc文件格式中,这是根据htk书,大endian二进制文件。当我在matlab中打开这些文件时,有一些值似乎是头值或其他值,有谁知道我如何从主数据中分离头值?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-27 09:47:09

您可以使用matlab文件交换发布的unter bsd lincense中的代码。

代码语言:javascript
复制
function [ features, sampPeriod, parmKind ] = readhtk_lite( filename )
% READHTK_LITE Simple routine for reading HTK feature files.
%
%   [ FEATURES, SAMPPERIOD, PARMKIND ] = READHTK_LITE( FILENAME )
%   returns FEATURES from HTK [1] feature file specified by FILENAME,
%   along with sample period (s) in SAMPPERIOD and parameter kind
%   in PARAMKIND. Note that this function provides a trivial 
%   implementation with limited functionality. For fully featured 
%   support of HTK I/O refer for example to the VOICEBOX toolbox [2].
%   
%   Inputs
%           FILENAME is a filename as string of a HTK feature file
%
%   Outputs
%           FEATURES is a feature matrix with feature vectors 
%           as rows and feature dimensions as columns
%
%           SAMPPERIOD is a sample period (s)
%
%           PARMKIND is a code indicating a sample kind
%           (see Sec. 5.10.1 of [1], pp. 80-81)
%
%   Example
%           [ features, sampPeriod, parmKind ] = readhtk_lite( 'sp10_htk.mfc' );
%
%   References
%
%           [1] Young, S., Evermann, G., Gales, M., Hain, T., Kershaw, D., 
%               Liu, X., Moore, G., Odell, J., Ollason, D., Povey, D., 
%               Valtchev, V., Woodland, P., 2006. The HTK Book (for HTK 
%               Version 3.4.1). Engineering Department, Cambridge University.
%               (see also: http://htk.eng.cam.ac.uk)
%
%           [2] VOICEBOX: MATLAB toolbox for speech processing by Mike Brookes
%               url: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html

%   Author: Kamil Wojcicki, September 2011


    mfcfile = fopen( filename, 'r', 'b' );

    nSamples = fread( mfcfile, 1, 'int32' );
    sampPeriod = fread( mfcfile, 1, 'int32' )*1E-7;
    sampSize = 0.25*fread( mfcfile, 1, 'int16' );
    parmKind = fread( mfcfile, 1, 'int16' );

    features = fread( mfcfile, [ sampSize, nSamples ], 'float' ).';

    fclose( mfcfile );


% EOF
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28761304

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档