function k =  my_dog(Signal, fs)


load('My_dog.mat')
% % [Signal, fs] = audioread('long_sample_1.wav');
% % if (size(Signal,2)>1)
% %     Signal = (sum(Signal,2)/2);% convert to MONO
% % end
% win = 0.31;
% step = 0.2;
%Testsamplemfcc = stFeatureExtractionmfcc(Signal, fs, win, step);
if length(Signal) < 13671
    Signal(end:13671) = 1;
end
 %spectrum model
% %  fs = 44100; 
% %  T = 1/fs;
% %  L = length(Features);
% %  f = fs*(0:L-1)/L;
% %  t = (0:L-1)*T;
% % 
win = 0.31;
%win = 0.310090703;  %% length of a single bark match with the window and step
step = 0.1;
curPos = 1;
windowLength = (win * fs);  
Stepf = round(step * fs); 
my_one_dog = cell(1,1);

Length_signal = length(Signal);
numberOfFrames =  floor((Length_signal-windowLength)/Stepf) + 1;

 
  % = Featuresaudio(1:windowLength);
% % Featuresaudio 
% [Features] = getDFT(Featuresaudio, 44100);
% % Deleted first row of coeficient
%mfccFeatures{1}(2,:) = [];  
%smallmfccFeatures{1}(2,:) = [];

%mfccFeatures_mydog{1}(4:13,:) = []; 
mfccFeatures_mydog{1}(1,:) = []
% % smallmfccFeatures{1}(4:13,:) = [];


Ham = window(@hamming, windowLength);
for i = 1:numberOfFrames
    frame  = (Signal(curPos:curPos+windowLength-1));
    frame  = frame .* Ham;
    Curframe{i} =  stFeatureExtractionmfcc(frame, fs, 0.08, 0.035);
    %Curframe{i} = mean(Curframe{i},2);
    Curframe{i} = Curframe{i};   % in case of transposing
    %Curframe{i} = sum(Curframe{i});
   % Curframe{i} = sum(Curframe{i},2);
   % d{i}= ((Curframe{i}^2)-(mfccFeatures{1}^2)); 
    
   
 % % deleted first coeficient
 Curframe{i}(1,:) = [];
 %Curframe{i}(4:13,:) = [];
 
 
 % % All coeficient
 my_one_dog{i}= ((Curframe{i}-mfccFeatures_mydog{1}).^2);
 
 
    
 
     my_one_dog{i} = sum(my_one_dog{i});
     my_one_dog{i} = sum(my_one_dog{i},2);

    curPos = curPos + Stepf;    
  
end
% % Curframe= cell2mat(Curframe);
% % Length_of_Curframe = length(Curframe);
% % End_value_Curframe = ((sum(Curframe,2))/Length_of_Curframe);
% % 26+
% % d = ((End_value_Curframe - mfccFeatures{1})^2)
my_one_dog = cell2mat(my_one_dog);



my_one_dog_result = zeros(1,1);
for i = 1:numberOfFrames
    if my_one_dog(i) > 45
       
        my_one_dog_result(i) = 0; 
    else
        my_one_dog_result(i) = 1;
    end
        
end
result = zeros(1,1);

my_one_dog_result   = logical(my_one_dog_result);

result = my_one_dog_result;



idx = zeros(1,1);
if all(result(:) == 0) 
        fprintf('Dog wasnt found in any frame')
else 
   idx  = find(result(:) == 1);
         %fprintf('Dog detected in frame number %d\n',idx(:))
         for i = 1:length(idx);
             idx(i) = idx(i) *0.1 - 0.05 ;  % shifted 0.05 for more acurrate result
         end 
 
 idx = round(idx,2);

  fprintf('Dog detected at second %0.2f\n',idx(:))  


end





% X = pdist2(Testsamplemfcc,mfccFeatures{1}, 'euclidean');
% pcolor(Testsamplemfcc)
% Calculated_distance = ((Testsamplemfcc-mfccFeatures{1}).^2);
% Sum_of_rows = sum(Calculated_distance);
% Sum_of_columns = sum(Sum_of_rows,2)
%  















% % if Sum_of_columns < 150;
% %    disp('Dog detected ')
% % else
% %     disp('Dog was not detected')
% % end
% % 
% % corrcoef(Testsamplemfcc,mfccFeatures{1});
% % subplot(2,2,1)
% % 
% % imagesc(Testsamplemfcc)
% % xlabel('Number of samples')
% % ylabel('Mfccs coeficient')
% % title('TestSampleMF-Cepstrum')
% % colorbar
% % subplot(2,2,2)
% % imagesc(mfccFeatures{1})
% % xlabel('Number of samples')
% % ylabel('Mfccs coeficient')
% % title('ModelMF-Cepstrum')
% % colorbar
% % 
% % 