clc;
clear all;
close all;
[A,FS]=audioread('D:\GOPI\DIGITAL_SPEECH_PROCESSING_USING_MATLAB\data\train\s1.wav');
S=A';
[res1,res2,speechsegment,utforste,ltforste,ltforzcr]=endpointdetection(S,FS);
%function [SG1,SG2,SG3]=spectrogram(speechsegment,FS)
n1=nextpow2(FS*10*10^(-3));
N1=2^n1;
n2=nextpow2(FS*20*10^(-3));
N2=2^n2;
n3=nextpow2(FS*40*10^(-3));
N3=2^n3;
N=max([N1 N2 N3]);
SG1=blkproc(speechsegment,[1 1],[0 N1-1], 'sg(x,P1)',N3);
SG2=blkproc(speechsegment,[1 1],[0 N2-1], 'sg(x,P1)',N3);
SG3=blkproc(speechsegment,[1 1],[0 N3-1], 'sg(x,P1)',N3);
figure
subplot(2,2,1)
plot(speechsegment)
subplot(2,2,2)
imagesc(10*log10(SG1))
title('Spectrogram with window size 15 ms')
subplot(2,2,3)
imagesc(10*log10(SG2))
title('Spectrogram with window size 20 ms')
subplot(2,2,4)
imagesc(10*log10(SG3))
title('Spectrogram with window size 25 ms')
figure
subplot(3,2,1)
plot(SG1(:,3000))
subplot(3,2,3)
plot(SG2(:,3000))
subplot(3,2,5)
plot(SG3(:,3000))
subplot(3,2,2)
plot(SG1(125,:))
subplot(3,2,4)
plot(SG2(125,:))
subplot(3,2,6)
plot(SG3(125,:))


