Error using fread Invalid file identifier in Microsoft MSR ToolKit
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Sonal Joshi
il 23 Nov 2016
Commentato: Sonal Joshi
il 21 Lug 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 Commenti
Risposta accettata
Walter Roberson
il 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 Commenti
Vinay H
il 29 Mag 2018
Modificato: Walter Roberson
il 6 Giu 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Historical Contests in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!