gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 18:04:54 25 4
gpt4 key购买 nike

我运行 HTK 包以从我的数据中提取 MFCC 特征。但是现在这个功能存储在 .mfc 文件格式中,根据 htk 书,big endian 二进制文件。当我在 matlab 中打开这些文件时,有一些值似乎是 header 值或其他东西,任何人都知道如何将 header 值与主数据分开?

最佳答案

您可以使用来自 matlab file exchange 的代码在 bsd lincense 下发布

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

关于matlab - 在matlab中读取HTK二进制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28761304/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com