function [segs_r, classes_r] = segmentTrue(fileName)
% [segs_r, classes_r] = segmentTrue(fileName)
% This function creates a mat file that contains information about the true
% class labels of the segments an audio stream.
% input:
%    - fileName: the file name of the wav file
% output:
%    - segs_r: an Nx2 matrix containing the beginning (1st column) and end
%    (2nd column) of the segments (in seconds)
%    - classes_r: an array containing the respective class labels
% When the function is finished a mat file is created named
% fileName_true.mat, that contains the segmentation information.

% remove extension (.wav), if existing
if (length(fileName>4))
    if (fileName(end-3:end)=='.wav')
        fileName = fileName(1:end-4);
    end
end

N = input('Give number of segments:');

segs_r(1,1) = 0.0;

for (i=1:N-1)
    temp = input(sprintf('End of segment %d: (in seconds)',i));
    segs_r(i,2) = temp;
    segs_r(i+1,1) = temp;
    classes_r(i) = input(sprintf('Give class for segment %.2f-%.2f:',segs_r(i,1),segs_r(i,2)));                    
end
Fs = 16000;
Len = wavread(fileName,'size');
L = Len(1);
segs_r(N,2) = L/Fs;
classes_r(N) = input(sprintf('Give class for segment %.2f-%.2f:',segs_r(N,1),segs_r(N,2)));
fprintf('File %s written!\n',sprintf('%s_true',fileName));
save(sprintf('%s_true',fileName),'segs_r','classes_r')