diff --git a/casestudy1/19BEC001MLSCVA01.pdf b/casestudy1/19BEC001MLSCVA01.pdf new file mode 100644 index 0000000..9621875 Binary files /dev/null and b/casestudy1/19BEC001MLSCVA01.pdf differ diff --git a/casestudy1/mlscv_casestudy1.pdf b/casestudy1/mlscv_casestudy1.pdf new file mode 100644 index 0000000..b088f1b Binary files /dev/null and b/casestudy1/mlscv_casestudy1.pdf differ diff --git a/casestudy1/question1/STEn_STM_calc.m b/casestudy1/question1/STEn_STM_calc.m new file mode 100644 index 0000000..eca757b --- /dev/null +++ b/casestudy1/question1/STEn_STM_calc.m @@ -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 + diff --git a/casestudy1/question1/abhishek_record.wav b/casestudy1/question1/abhishek_record.wav new file mode 100644 index 0000000..31dee6c Binary files /dev/null and b/casestudy1/question1/abhishek_record.wav differ diff --git a/casestudy1/question1/calc_MFCC.m b/casestudy1/question1/calc_MFCC.m new file mode 100644 index 0000000..d6b039b --- /dev/null +++ b/casestudy1/question1/calc_MFCC.m @@ -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 \ No newline at end of file diff --git a/casestudy1/question1/question1.mlx b/casestudy1/question1/question1.mlx new file mode 100644 index 0000000..e01d6bd Binary files /dev/null and b/casestudy1/question1/question1.mlx differ diff --git a/casestudy1/question1/question1_fig.jpg b/casestudy1/question1/question1_fig.jpg new file mode 100644 index 0000000..2e26695 Binary files /dev/null and b/casestudy1/question1/question1_fig.jpg differ diff --git a/casestudy1/question1/spec_calc.m b/casestudy1/question1/spec_calc.m new file mode 100644 index 0000000..29448d2 --- /dev/null +++ b/casestudy1/question1/spec_calc.m @@ -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'; diff --git a/casestudy1/question2/STEn_STM_calc.m b/casestudy1/question2/STEn_STM_calc.m new file mode 100644 index 0000000..eca757b --- /dev/null +++ b/casestudy1/question2/STEn_STM_calc.m @@ -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 + diff --git a/casestudy1/question2/abhishek_aiu.wav b/casestudy1/question2/abhishek_aiu.wav new file mode 100644 index 0000000..6c1071f Binary files /dev/null and b/casestudy1/question2/abhishek_aiu.wav differ diff --git a/casestudy1/question2/abhishek_second.wav b/casestudy1/question2/abhishek_second.wav new file mode 100644 index 0000000..4de69d0 Binary files /dev/null and b/casestudy1/question2/abhishek_second.wav differ diff --git a/casestudy1/question2/calc_MFCC.m b/casestudy1/question2/calc_MFCC.m new file mode 100644 index 0000000..d6b039b --- /dev/null +++ b/casestudy1/question2/calc_MFCC.m @@ -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 \ No newline at end of file diff --git a/casestudy1/question2/figure1.jpg b/casestudy1/question2/figure1.jpg new file mode 100644 index 0000000..27ee7e0 Binary files /dev/null and b/casestudy1/question2/figure1.jpg differ diff --git a/casestudy1/question2/figure2.jpg b/casestudy1/question2/figure2.jpg new file mode 100644 index 0000000..bbd1169 Binary files /dev/null and b/casestudy1/question2/figure2.jpg differ diff --git a/casestudy1/question2/figure3.jpg b/casestudy1/question2/figure3.jpg new file mode 100644 index 0000000..7411383 Binary files /dev/null and b/casestudy1/question2/figure3.jpg differ diff --git a/casestudy1/question2/figure4.jpg b/casestudy1/question2/figure4.jpg new file mode 100644 index 0000000..8005285 Binary files /dev/null and b/casestudy1/question2/figure4.jpg differ diff --git a/casestudy1/question2/figure5.jpg b/casestudy1/question2/figure5.jpg new file mode 100644 index 0000000..11204ff Binary files /dev/null and b/casestudy1/question2/figure5.jpg differ diff --git a/casestudy1/question2/figure6.jpg b/casestudy1/question2/figure6.jpg new file mode 100644 index 0000000..9bd0d7e Binary files /dev/null and b/casestudy1/question2/figure6.jpg differ diff --git a/casestudy1/question2/figure7.jpg b/casestudy1/question2/figure7.jpg new file mode 100644 index 0000000..3371096 Binary files /dev/null and b/casestudy1/question2/figure7.jpg differ diff --git a/casestudy1/question2/question2.mlx b/casestudy1/question2/question2.mlx new file mode 100644 index 0000000..ea2ae0c Binary files /dev/null and b/casestudy1/question2/question2.mlx differ diff --git a/casestudy1/question2/spec_calc.m b/casestudy1/question2/spec_calc.m new file mode 100644 index 0000000..29448d2 --- /dev/null +++ b/casestudy1/question2/spec_calc.m @@ -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'; diff --git a/casestudy1/question3/STEn_STM_calc.m b/casestudy1/question3/STEn_STM_calc.m new file mode 100644 index 0000000..eca757b --- /dev/null +++ b/casestudy1/question3/STEn_STM_calc.m @@ -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 + diff --git a/casestudy1/question3/abhishek_aiu.wav b/casestudy1/question3/abhishek_aiu.wav new file mode 100644 index 0000000..6c1071f Binary files /dev/null and b/casestudy1/question3/abhishek_aiu.wav differ diff --git a/casestudy1/question3/abhishek_second.wav b/casestudy1/question3/abhishek_second.wav new file mode 100644 index 0000000..4de69d0 Binary files /dev/null and b/casestudy1/question3/abhishek_second.wav differ diff --git a/casestudy1/question3/calc_MFCC.m b/casestudy1/question3/calc_MFCC.m new file mode 100644 index 0000000..d6b039b --- /dev/null +++ b/casestudy1/question3/calc_MFCC.m @@ -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 \ No newline at end of file diff --git a/casestudy1/question3/fig1.jpg b/casestudy1/question3/fig1.jpg new file mode 100644 index 0000000..4d4b1f5 Binary files /dev/null and b/casestudy1/question3/fig1.jpg differ diff --git a/casestudy1/question3/fig10.jpg b/casestudy1/question3/fig10.jpg new file mode 100644 index 0000000..a80e16c Binary files /dev/null and b/casestudy1/question3/fig10.jpg differ diff --git a/casestudy1/question3/fig2.jpg b/casestudy1/question3/fig2.jpg new file mode 100644 index 0000000..dc6cce4 Binary files /dev/null and b/casestudy1/question3/fig2.jpg differ diff --git a/casestudy1/question3/fig3.jpg b/casestudy1/question3/fig3.jpg new file mode 100644 index 0000000..1e200aa Binary files /dev/null and b/casestudy1/question3/fig3.jpg differ diff --git a/casestudy1/question3/fig4.jpg b/casestudy1/question3/fig4.jpg new file mode 100644 index 0000000..e79852e Binary files /dev/null and b/casestudy1/question3/fig4.jpg differ diff --git a/casestudy1/question3/fig5.jpg b/casestudy1/question3/fig5.jpg new file mode 100644 index 0000000..f52db93 Binary files /dev/null and b/casestudy1/question3/fig5.jpg differ diff --git a/casestudy1/question3/fig6.jpg b/casestudy1/question3/fig6.jpg new file mode 100644 index 0000000..3a98331 Binary files /dev/null and b/casestudy1/question3/fig6.jpg differ diff --git a/casestudy1/question3/fig7.jpg b/casestudy1/question3/fig7.jpg new file mode 100644 index 0000000..ea9feed Binary files /dev/null and b/casestudy1/question3/fig7.jpg differ diff --git a/casestudy1/question3/fig8.jpg b/casestudy1/question3/fig8.jpg new file mode 100644 index 0000000..0fd47a4 Binary files /dev/null and b/casestudy1/question3/fig8.jpg differ diff --git a/casestudy1/question3/fig9.jpg b/casestudy1/question3/fig9.jpg new file mode 100644 index 0000000..dafc7ef Binary files /dev/null and b/casestudy1/question3/fig9.jpg differ diff --git a/casestudy1/question3/question3.mlx b/casestudy1/question3/question3.mlx new file mode 100644 index 0000000..0b704f3 Binary files /dev/null and b/casestudy1/question3/question3.mlx differ diff --git a/casestudy1/question3/spec_calc.m b/casestudy1/question3/spec_calc.m new file mode 100644 index 0000000..29448d2 --- /dev/null +++ b/casestudy1/question3/spec_calc.m @@ -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'; diff --git a/casestudy1/question4/STEn_STM_calc.m b/casestudy1/question4/STEn_STM_calc.m new file mode 100644 index 0000000..eca757b --- /dev/null +++ b/casestudy1/question4/STEn_STM_calc.m @@ -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 + diff --git a/casestudy1/question4/abhishek_aiu.wav b/casestudy1/question4/abhishek_aiu.wav new file mode 100644 index 0000000..6c1071f Binary files /dev/null and b/casestudy1/question4/abhishek_aiu.wav differ diff --git a/casestudy1/question4/abhishek_second.wav b/casestudy1/question4/abhishek_second.wav new file mode 100644 index 0000000..4de69d0 Binary files /dev/null and b/casestudy1/question4/abhishek_second.wav differ diff --git a/casestudy1/question4/calc_MFCC.m b/casestudy1/question4/calc_MFCC.m new file mode 100644 index 0000000..d6b039b --- /dev/null +++ b/casestudy1/question4/calc_MFCC.m @@ -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 \ No newline at end of file diff --git a/casestudy1/question4/fig1.jpg b/casestudy1/question4/fig1.jpg new file mode 100644 index 0000000..b22262f Binary files /dev/null and b/casestudy1/question4/fig1.jpg differ diff --git a/casestudy1/question4/fig2.jpg b/casestudy1/question4/fig2.jpg new file mode 100644 index 0000000..0b5edaa Binary files /dev/null and b/casestudy1/question4/fig2.jpg differ diff --git a/casestudy1/question4/question4.mlx b/casestudy1/question4/question4.mlx new file mode 100644 index 0000000..878e3ad Binary files /dev/null and b/casestudy1/question4/question4.mlx differ diff --git a/casestudy1/question4/spec_calc.m b/casestudy1/question4/spec_calc.m new file mode 100644 index 0000000..29448d2 --- /dev/null +++ b/casestudy1/question4/spec_calc.m @@ -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'; diff --git a/casestudy1/question5/STEn_STM_calc.m b/casestudy1/question5/STEn_STM_calc.m new file mode 100644 index 0000000..eca757b --- /dev/null +++ b/casestudy1/question5/STEn_STM_calc.m @@ -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 + diff --git a/casestudy1/question5/abhishek_aiu.wav b/casestudy1/question5/abhishek_aiu.wav new file mode 100644 index 0000000..6c1071f Binary files /dev/null and b/casestudy1/question5/abhishek_aiu.wav differ diff --git a/casestudy1/question5/abhishek_second.wav b/casestudy1/question5/abhishek_second.wav new file mode 100644 index 0000000..4de69d0 Binary files /dev/null and b/casestudy1/question5/abhishek_second.wav differ diff --git a/casestudy1/question5/calc_MFCC.m b/casestudy1/question5/calc_MFCC.m new file mode 100644 index 0000000..d6b039b --- /dev/null +++ b/casestudy1/question5/calc_MFCC.m @@ -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 \ No newline at end of file diff --git a/casestudy1/question5/fig1.jpg b/casestudy1/question5/fig1.jpg new file mode 100644 index 0000000..b8e85e7 Binary files /dev/null and b/casestudy1/question5/fig1.jpg differ diff --git a/casestudy1/question5/question5.mlx b/casestudy1/question5/question5.mlx new file mode 100644 index 0000000..6e973e7 Binary files /dev/null and b/casestudy1/question5/question5.mlx differ diff --git a/casestudy1/question5/spec_calc.m b/casestudy1/question5/spec_calc.m new file mode 100644 index 0000000..29448d2 --- /dev/null +++ b/casestudy1/question5/spec_calc.m @@ -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';