-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All the files and source codes for the Case Study 1
- Loading branch information
Showing
52 changed files
with
645 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function [STEn, STMag] = STEn_STM_calc(speech, WL_samp, WS_Samp, fs) | ||
|
||
|
||
|
||
Num_frames = round( (length(speech)-WL_samp)/WS_Samp ); | ||
STEn = zeros(1,Num_frames); | ||
STMag = zeros(1,Num_frames); | ||
|
||
for i=1:Num_frames | ||
startsamp = (i-1)*WS_Samp+1; | ||
EndSamp = startsamp+WL_samp-1; | ||
CurrSpeech = speech(startsamp :EndSamp); | ||
CurrSpeechWin = (CurrSpeech).*hamming(WL_samp); | ||
STEn(i) = sum(CurrSpeechWin.*CurrSpeechWin); | ||
STMag(i) = sum(abs(CurrSpeechWin)); | ||
|
||
|
||
% if(i==11) | ||
% | ||
% FFTSpec = fft(CurrSpeechWin, 512); | ||
% freq = (0:256)*(fs/512); | ||
% figure; plot (freq, 20*log10( abs(FFTSpec(1:257))),'LineWidth',2); | ||
% temp=1; | ||
% end | ||
end | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
function [MFCC, logFiltBankOut, logFiltBankFreq] = calc_MFCC(speech, N_filters, N_FFT, fs) | ||
% calculate the MFCC now. | ||
fmax = fs/2; | ||
Mel_fmax = 1127*log(1+ (fmax/700)); | ||
|
||
% obtain the center frequencies in mel scale | ||
N = N_filters; | ||
% N_FFT = 512; | ||
m=0:(N+1); | ||
c = m*(Mel_fmax/(N+1)); | ||
|
||
% convert these to linear frequencies | ||
h = 700* (exp(c/1127) - 1); | ||
|
||
% convert to DFT indices | ||
g = round( (N_FFT*h)/fs) + 1; % +1 added due to MatLab indexing 1 | ||
|
||
% Obtain the filterbank coefficients | ||
temp=1; | ||
|
||
H = zeros(N, (N_FFT/2)+1); | ||
for m=2:N+1 | ||
for k=1:(N_FFT/2)+1 | ||
if( k< g(m-1) || k>g(m+1)) | ||
H(m-1, k) = 0; | ||
else | ||
if(k>=g(m-1) && k<=g(m)) | ||
H(m-1, k) = (k-g(m-1))/(g(m)-g(m-1)); | ||
else | ||
H(m-1, k) = (g(m+1)-k)/(g(m+1)-g(m)); | ||
end | ||
|
||
end | ||
end | ||
end | ||
|
||
|
||
%%%%%%%%%%%%calculating MFCC %%%%%%%%%% | ||
|
||
spec = abs( fft(speech.*hamming(length(speech)), N_FFT)); | ||
|
||
% Filter the spectrum using | ||
spec = spec( 1: (N_FFT/2)+1); | ||
|
||
% size(spec) | ||
% size(H) | ||
Fout = H* spec; | ||
logFiltBankOut = log(Fout); | ||
logFiltBankFreq = g(2:N+1) * (fs/N_FFT); | ||
|
||
% DCT calculation | ||
|
||
for l=1:13 | ||
DCTout_temp=0; | ||
for m=1:N | ||
DCTout_temp = DCTout_temp+ log(Fout(m))*cos( (pi*l*(m-0.5)) /N); | ||
end | ||
MFCC(l) = DCTout_temp; | ||
end | ||
|
||
|
||
% figure; | ||
% for m=1:N | ||
% | ||
% plot(H(m, :), 'LineWidth', 2); | ||
% hold on | ||
% end | ||
% axis tight |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
function [b,f,t] = spec_calc(data,NFFT,fs,windowSig,o_lap) | ||
|
||
L = length(windowSig); | ||
M = L - o_lap; | ||
datalen = length(data); | ||
|
||
noOfFrames = round(datalen/M); | ||
frameInd = 1; | ||
for i=1:noOfFrames | ||
w_start = (i-1)*M + 1; | ||
w_end = w_start + L -1; | ||
|
||
if(w_start < 1) | ||
w_start = 1; | ||
end; | ||
if(w_end > length(data)) | ||
break; | ||
|
||
end; | ||
|
||
|
||
|
||
h = windowSig; | ||
Signal = data(w_start:w_end); | ||
|
||
sn = Signal.*h; | ||
XkTmep = fft(sn,NFFT); | ||
Xk(frameInd,:) = XkTmep(1:NFFT/2); | ||
|
||
|
||
frameInd = frameInd + 1; | ||
end | ||
f = (1:1:NFFT/2)*(fs/NFFT); | ||
t = 0:(M/fs):(datalen/fs); | ||
b = Xk'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function [STEn, STMag] = STEn_STM_calc(speech, WL_samp, WS_Samp, fs) | ||
|
||
|
||
|
||
Num_frames = round( (length(speech)-WL_samp)/WS_Samp ); | ||
STEn = zeros(1,Num_frames); | ||
STMag = zeros(1,Num_frames); | ||
|
||
for i=1:Num_frames | ||
startsamp = (i-1)*WS_Samp+1; | ||
EndSamp = startsamp+WL_samp-1; | ||
CurrSpeech = speech(startsamp :EndSamp); | ||
CurrSpeechWin = (CurrSpeech).*hamming(WL_samp); | ||
STEn(i) = sum(CurrSpeechWin.*CurrSpeechWin); | ||
STMag(i) = sum(abs(CurrSpeechWin)); | ||
|
||
|
||
% if(i==11) | ||
% | ||
% FFTSpec = fft(CurrSpeechWin, 512); | ||
% freq = (0:256)*(fs/512); | ||
% figure; plot (freq, 20*log10( abs(FFTSpec(1:257))),'LineWidth',2); | ||
% temp=1; | ||
% end | ||
end | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
function [MFCC, logFiltBankOut, logFiltBankFreq] = calc_MFCC(speech, N_filters, N_FFT, fs) | ||
% calculate the MFCC now. | ||
fmax = fs/2; | ||
Mel_fmax = 1127*log(1+ (fmax/700)); | ||
|
||
% obtain the center frequencies in mel scale | ||
N = N_filters; | ||
% N_FFT = 512; | ||
m=0:(N+1); | ||
c = m*(Mel_fmax/(N+1)); | ||
|
||
% convert these to linear frequencies | ||
h = 700* (exp(c/1127) - 1); | ||
|
||
% convert to DFT indices | ||
g = round( (N_FFT*h)/fs) + 1; % +1 added due to MatLab indexing 1 | ||
|
||
% Obtain the filterbank coefficients | ||
temp=1; | ||
|
||
H = zeros(N, (N_FFT/2)+1); | ||
for m=2:N+1 | ||
for k=1:(N_FFT/2)+1 | ||
if( k< g(m-1) || k>g(m+1)) | ||
H(m-1, k) = 0; | ||
else | ||
if(k>=g(m-1) && k<=g(m)) | ||
H(m-1, k) = (k-g(m-1))/(g(m)-g(m-1)); | ||
else | ||
H(m-1, k) = (g(m+1)-k)/(g(m+1)-g(m)); | ||
end | ||
|
||
end | ||
end | ||
end | ||
|
||
|
||
%%%%%%%%%%%%calculating MFCC %%%%%%%%%% | ||
|
||
spec = abs( fft(speech.*hamming(length(speech)), N_FFT)); | ||
|
||
% Filter the spectrum using | ||
spec = spec( 1: (N_FFT/2)+1); | ||
|
||
% size(spec) | ||
% size(H) | ||
Fout = H* spec; | ||
logFiltBankOut = log(Fout); | ||
logFiltBankFreq = g(2:N+1) * (fs/N_FFT); | ||
|
||
% DCT calculation | ||
|
||
for l=1:13 | ||
DCTout_temp=0; | ||
for m=1:N | ||
DCTout_temp = DCTout_temp+ log(Fout(m))*cos( (pi*l*(m-0.5)) /N); | ||
end | ||
MFCC(l) = DCTout_temp; | ||
end | ||
|
||
|
||
% figure; | ||
% for m=1:N | ||
% | ||
% plot(H(m, :), 'LineWidth', 2); | ||
% hold on | ||
% end | ||
% axis tight |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
function [b,f,t] = spec_calc(data,NFFT,fs,windowSig,o_lap) | ||
|
||
L = length(windowSig); | ||
M = L - o_lap; | ||
datalen = length(data); | ||
|
||
noOfFrames = round(datalen/M); | ||
frameInd = 1; | ||
for i=1:noOfFrames | ||
w_start = (i-1)*M + 1; | ||
w_end = w_start + L -1; | ||
|
||
if(w_start < 1) | ||
w_start = 1; | ||
end; | ||
if(w_end > length(data)) | ||
break; | ||
|
||
end; | ||
|
||
|
||
|
||
h = windowSig; | ||
Signal = data(w_start:w_end); | ||
|
||
sn = Signal.*h; | ||
XkTmep = fft(sn,NFFT); | ||
Xk(frameInd,:) = XkTmep(1:NFFT/2); | ||
|
||
|
||
frameInd = frameInd + 1; | ||
end | ||
f = (1:1:NFFT/2)*(fs/NFFT); | ||
t = 0:(M/fs):(datalen/fs); | ||
b = Xk'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function [STEn, STMag] = STEn_STM_calc(speech, WL_samp, WS_Samp, fs) | ||
|
||
|
||
|
||
Num_frames = round( (length(speech)-WL_samp)/WS_Samp ); | ||
STEn = zeros(1,Num_frames); | ||
STMag = zeros(1,Num_frames); | ||
|
||
for i=1:Num_frames | ||
startsamp = (i-1)*WS_Samp+1; | ||
EndSamp = startsamp+WL_samp-1; | ||
CurrSpeech = speech(startsamp :EndSamp); | ||
CurrSpeechWin = (CurrSpeech).*hamming(WL_samp); | ||
STEn(i) = sum(CurrSpeechWin.*CurrSpeechWin); | ||
STMag(i) = sum(abs(CurrSpeechWin)); | ||
|
||
|
||
% if(i==11) | ||
% | ||
% FFTSpec = fft(CurrSpeechWin, 512); | ||
% freq = (0:256)*(fs/512); | ||
% figure; plot (freq, 20*log10( abs(FFTSpec(1:257))),'LineWidth',2); | ||
% temp=1; | ||
% end | ||
end | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
function [MFCC, logFiltBankOut, logFiltBankFreq] = calc_MFCC(speech, N_filters, N_FFT, fs) | ||
% calculate the MFCC now. | ||
fmax = fs/2; | ||
Mel_fmax = 1127*log(1+ (fmax/700)); | ||
|
||
% obtain the center frequencies in mel scale | ||
N = N_filters; | ||
% N_FFT = 512; | ||
m=0:(N+1); | ||
c = m*(Mel_fmax/(N+1)); | ||
|
||
% convert these to linear frequencies | ||
h = 700* (exp(c/1127) - 1); | ||
|
||
% convert to DFT indices | ||
g = round( (N_FFT*h)/fs) + 1; % +1 added due to MatLab indexing 1 | ||
|
||
% Obtain the filterbank coefficients | ||
temp=1; | ||
|
||
H = zeros(N, (N_FFT/2)+1); | ||
for m=2:N+1 | ||
for k=1:(N_FFT/2)+1 | ||
if( k< g(m-1) || k>g(m+1)) | ||
H(m-1, k) = 0; | ||
else | ||
if(k>=g(m-1) && k<=g(m)) | ||
H(m-1, k) = (k-g(m-1))/(g(m)-g(m-1)); | ||
else | ||
H(m-1, k) = (g(m+1)-k)/(g(m+1)-g(m)); | ||
end | ||
|
||
end | ||
end | ||
end | ||
|
||
|
||
%%%%%%%%%%%%calculating MFCC %%%%%%%%%% | ||
|
||
spec = abs( fft(speech.*hamming(length(speech)), N_FFT)); | ||
|
||
% Filter the spectrum using | ||
spec = spec( 1: (N_FFT/2)+1); | ||
|
||
% size(spec) | ||
% size(H) | ||
Fout = H* spec; | ||
logFiltBankOut = log(Fout); | ||
logFiltBankFreq = g(2:N+1) * (fs/N_FFT); | ||
|
||
% DCT calculation | ||
|
||
for l=1:13 | ||
DCTout_temp=0; | ||
for m=1:N | ||
DCTout_temp = DCTout_temp+ log(Fout(m))*cos( (pi*l*(m-0.5)) /N); | ||
end | ||
MFCC(l) = DCTout_temp; | ||
end | ||
|
||
|
||
% figure; | ||
% for m=1:N | ||
% | ||
% plot(H(m, :), 'LineWidth', 2); | ||
% hold on | ||
% end | ||
% axis tight |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
function [b,f,t] = spec_calc(data,NFFT,fs,windowSig,o_lap) | ||
|
||
L = length(windowSig); | ||
M = L - o_lap; | ||
datalen = length(data); | ||
|
||
noOfFrames = round(datalen/M); | ||
frameInd = 1; | ||
for i=1:noOfFrames | ||
w_start = (i-1)*M + 1; | ||
w_end = w_start + L -1; | ||
|
||
if(w_start < 1) | ||
w_start = 1; | ||
end; | ||
if(w_end > length(data)) | ||
break; | ||
|
||
end; | ||
|
||
|
||
|
||
h = windowSig; | ||
Signal = data(w_start:w_end); | ||
|
||
sn = Signal.*h; | ||
XkTmep = fft(sn,NFFT); | ||
Xk(frameInd,:) = XkTmep(1:NFFT/2); | ||
|
||
|
||
frameInd = frameInd + 1; | ||
end | ||
f = (1:1:NFFT/2)*(fs/NFFT); | ||
t = 0:(M/fs):(datalen/fs); | ||
b = Xk'; |
Oops, something went wrong.