Error using fread Invalid file identifier in Microsoft MSR ToolKit
조회 수: 1 (최근 30일)
이전 댓글 표시
Error using fread
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in htkread (line 8)
nframes = fread(fid, 1, 'int32'); % number of frames
Error in DebugCode (line 13)
data{ix} = htkread(filenames{ix});
The code of functions where the errors arise are:
function gmm = mapAdapt(dataList, ubmFilename, tau, config, gmmFilename)
......
.
if ischar(dataList) || iscellstr(dataList),
dataList = load_data(dataList);
end
if ~iscell(dataList),
error('Oops! dataList should be a cell array!');
end
nfiles = length(dataList);
.
..
.......
end
*****************************************************************************
function data = load_data(datalist)
% load all data into memory
if ~iscellstr(datalist)
fid = fopen(datalist, 'rt');
filenames = textscan(fid, '%s');
fclose(fid);
filenames = filenames{1};
else
filenames = datalist;
end
nfiles = size(filenames, 1);
data = cell(nfiles, 1);
for ix = 1 : nfiles,
data{ix} = htkread(filenames{ix});
end
**************************************************************************************
function [data, frate, feakind] = htkread(filename)
% reads features with HTK format
%
% Omid Sadjadi <s.omid.sadjadi@gmail.com>
% Microsoft Research, Conversational Systems Research Center
fid = fopen(filename, 'rb', 'ieee-be');
nframes = fread(fid, 1, 'int32'); % number of frames %%ERROR
frate = fread(fid, 1, 'int32'); % frame rate in 100 nano-seconds unit
nbytes = fread(fid, 1, 'short'); % number of bytes per feature value
feakind = fread(fid, 1, 'short'); % 9 is USER
ndim = nbytes / 4; % feature dimension (4 bytes per value)
data = fread(fid, [ndim, nframes], 'float');
fclose(fid);
datalist.txt is a file with 6300 entries like
htkfiles\fadg0_si1279.htk
htkfiles\fadg0_si1909.htk
htkfiles\fadg0_si649.htk
htkfiles\fadg0_sx109.htk
htkfiles\fadg0_sx19.htk
htkfiles\fadg0_sx199.htk
htkfiles\fadg0_sx289.htk
htkfiles\fadg0_sx379.htk
htkfiles\faem0_sa1.htk
htkfiles\faem0_sa2.htk
htkfiles\faem0_si1392.htk
htkfiles\faem0_si2022.htk
htkfiles\faem0_si762.htk
htkfiles\faem0_sx132.htk
htkfiles\faem0_sx222.htk
htkfiles\faem0_sx312.htk
htkfiles\faem0_sx402.htk
htkfiles\faem0_sx42.htk
htkfiles\fajw0_sa1.htk
htkfiles\fajw0_sa2.htk
htkfiles\fajw0_si1263.htk
htkfiles\fajw0_si1893.htk
댓글 수: 0
채택된 답변
Walter Roberson
2016년 11월 23일
One or more of the files named in that list do not exist relative to your current directory.
The code
fid = fopen(filename, 'rb', 'ieee-be');
would be better as
[fid, message] = fopen(filename, 'rb', 'ieee-be');
if fid < 0
error('Failed to open file "%s" because "%s", filename, message);
end
댓글 수: 3
Vinay H
2018년 5월 29일
편집: Walter Roberson
2018년 6월 6일
How did you get dataList. I downloaded from https://www.microsoft.com/en-us/download/details.aspx?id=52279 and it does not have database to train. Please let me know how you got database.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!