function [TST, TPT, NST, TSR, NSR, PPR] = tempo(x, fs, delka_ramce, init, filename)
%% Funkce pro vypocet parametru souvsejici s tempem a pauzovanim
% 
% TST - absolutni trvani recoveho signalu (Total Speech Time) [s],
% TPT - celkove trvani pauz (Total Pause Time) [s],
% NST - trvani ciste recoveho signalu (Net Speech Time) [s],
%
% TSR - Absolutni tempo(Total Speech Rate) [slabika/s],
% NSR - Tempo ciste recoveho signalu (Net Speech Rate) [slabika/s],
%
% PPR - Procentualni pomer pauz (Percentual Pause Ratio) [%]

%% Vypocet
[VADi]=detektor(x,fs,delka_ramce,init);

full_time = length(x)/fs;
casova_delka_ramce = full_time/length(VADi);

%odstraneni nul na zacatku
for i=1:length(VADi)
    if(VADi(i)==1)
       newVADi = VADi(i:length(VADi)); 
       break;
    end
end

%odstraneni nul na konci
for i=1:length(newVADi)
    if(newVADi(length(newVADi)+1-i) == 1)
        newnewVADi = newVADi(1:length(newVADi)+1-i);
        break;
    end
end

TST = casova_delka_ramce * length(newnewVADi);


nullcount = 0;
pausecount = 0;
for i=1:length(newnewVADi)
   if(newnewVADi(i) == 0)
       nullcount = nullcount+1;       
   else
       if (nullcount >=3)
           pausecount = pausecount + nullcount;
       end
       nullcount = 0;    
   end    
end

TPT = pausecount * casova_delka_ramce;



%zjisteni cisla a poctu slabik ve vete
% po - nasleduje cislo nebo I-cislo
% -X          -I-X
%potrebujeme 

for i=1:length(filename)
   if filename(i) == '-'
      if filename(i+1) == 'l'
          strnr = filename(i+3);
          nr = str2num(strnr) +5;
          break;      
      else
          nr = str2num(filename(i+1));
          break;
      end
   end    
end

switch nr
    case 1        
        pocetslabik = 9;
        %file-1
    case 2        
        pocetslabik = 11;
        %file-2
    case 3        
        pocetslabik = 10;
        %file-3
    case 4
        pocetslabik = 11;
    case 5        
        pocetslabik = 9;
        %file-5
    case 6        
        pocetslabik = 9;
        %file-l-1
    case 7
        pocetslabik = 11;
        %file-l-2
    case 8
        pocetslabik = 10;
        %file-l-3
    case 9
        pocetslabik = 11;
        %file-l-4
    case 10
        pocetslabik = 9;
        %file-l-5
    otherwise
        %vypis error
        disp('Soubor nema zadanu hodnotu slabik');
end;

NST = TST - TPT;
TSR = pocetslabik / TST;
NSR = pocetslabik / NST;
PPR = (TPT/TST) * 100; 

