function [feature_matrix, labels] = ...
    get_speaker_features_and_labels(db, field_name)
    % Extracts features and labels from all the samples corresponding
    % to the specified speakers.
    % db - Database of samples generated by gendb()
    % speakers - List of speakers for which to extract features
    % feature_matrix - Feature matrix for input to Diffusion Maps
    % labels - Label for each column of feature_matrix
    
    unique_field_values = get_field(db, field_name);
    if (strcmp(field_name, 'digit'))
       unique_field_values = cell2mat(unique_field_values);
       unique_field_values(:, 2) = '*';
       unique_field_values = mat2cell(unique_field_values, ...
           ones(size(unique_field_values,1), 1));
       unique_field_values = unique(unique_field_values);
    end
    
    feature_matrix = [];
    labels = [];
    total_entries = 0; % counter of handled entries
    
    progressbar;
    NUM_OF_UNIQUE_VALUES = length(unique_field_values);
    for k = 1:NUM_OF_UNIQUE_VALUES
        speaker_db = filterdb(db, field_name, unique_field_values{k});
        
        % extract features for all speaker samples
        func = @calc_mfcc;
%         func = @calc_stft;
        [features, num_of_success] = extract_features(speaker_db, func);
        
        if num_of_success > 0
            labels = [labels; ones(num_of_success, 1) * k];
            feature_matrix = [feature_matrix features];
            total_entries = total_entries + num_of_success;
        end
        
        progressbar(k/NUM_OF_UNIQUE_VALUES);
    end
    
    fprintf('Handled %d entries\n', total_entries);
end