function [y2, znelost, Y] = ZCR_final(y, Fs, delka_okna)

    [Y, pocet_oken, pocet_vzorku_okna, remainder] = SEG_A_DOPLN(y, Fs, delka_okna);    
    
    
    for n = 1:pocet_oken

        zcr_okna(n) = sum(abs(diff(Y(:,n)>0)))/pocet_vzorku_okna;          %vypocet ZCR jednotlivych oken
        gwn(:,n) = rand(pocet_vzorku_okna,1)-0.5;                          %Gaussuv bily sum pro kazde okno        
        zcr_sumu(n) = 0.1*(sum(abs(diff(gwn(:,n)>0)))/pocet_vzorku_okna);  %a vypocet jeho ZCR pro kazde okno
    
    end
    
    
    for n = 1:pocet_oken
                                                
        if zcr_okna(n) >= zcr_sumu(n)                                      %porovnej ZCR okna se ZCR sumu              
            znelost(n) = 0;            
        else            
            znelost(n) = 1;            
        end     
        
    end
    
    
    
    for n = 1:1:pocet_oken
    
        if znelost(n) == 0
            Y(:,n) = 0;
        else
            Y(:,n) = Y(:,n);
        end
        
    end

    y2 = reshape(Y,1,[]);
    y2 = y2(1:end - (pocet_vzorku_okna-remainder));
        
end

    

