Error using fread Invalid file identifier in Microsoft MSR ToolKit
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sonal Joshi
le 23 Nov 2016
Commenté : Sonal Joshi
le 21 Juil 2018
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 commentaires
Réponse acceptée
Walter Roberson
le 23 Nov 2016
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 commentaires
Vinay H
le 29 Mai 2018
Modifié(e) : Walter Roberson
le 6 Juin 2018
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Historical Contests dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!