-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwriteHTK.m
More file actions
26 lines (21 loc) · 886 Bytes
/
writeHTK.m
File metadata and controls
26 lines (21 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function [data] = writeHTK (data, output, directory)
filename = directory + "\" + output + ".mfc";
numVectors = length(data);
vectorPeriod = 200000;
numDims = length(data(1,:));
parmKind = 6;
% Open file for writing:
fid = fopen(filename, 'w', 'ieee-be');
% Write the header information%
fwrite(fid, numVectors, 'int32'); % number of vectors in file (4 byte int)
fwrite(fid, vectorPeriod, 'int32'); % sample period in 100ns units (4 byte int)
fwrite(fid, numDims * 4, 'int16'); % number of bytes per vector (2 byte int)
fwrite(fid, parmKind, 'int16'); % code for the sample kind (2 byte int)
% Write the data: one coefficient at a time:
for i = 1: numVectors
for j = 1:numDims
fwrite(fid, data(i, j), 'float32');
end
end
disp("HTK written: " + output + ".mfc");
end