Am performing speech enhancement using Spectral Subtraction code,There is an error in matrix dimensions when given wavwrite operation and the output is not in comparison with the given signal,237504 is the total samples of the given speech

1 view (last 30 days)
clc;
clear;
close all;
[x fs]=wavread('1f40.wav');
x(1,1)=0;
y=0.1*randn(size(x));
z=x+y;
Zf=fft(z1,237504);
Yf=fft(y,237504);
Pz=abs(Zf);
Py=abs(Yf);
ph=angle(Zf);
for n=1:1:236
Pzm{n}=Pz(((n*1000+1):(n*1000+1000)),1);%magnitude of corrupted
Pym{n}=Py(((n*1000+1):(n*1000+1000)),1); %mag of pure noise
phm{n}=ph((n*1000+1):(n*1000+1000),1); %phase of corrupted
snr{n} =10*log10( mean( Pzm{n} .^2) / mean( Pym{n} .^2));
if (snr{n}<-5);
alpha{n}=5;
elseif (-5<=snr{n} && snr{n}<=20)
alpha{n}=4-(3/20)*snr{n};
else
alpha{n}=1;
end
Ps{n}=(Pzm{n} .^2) - (alpha{n}*(Pym{n}.^2));
Co{n}=sqrt(Ps{n});
Z{n}=Co{n}.*exp(phm{n}*sqrt(-1));
r{n}=ifft(Z{n},1000);
end
xc=cell2mat(r);
xr=reshape(xc,236000,1);
wavwrite(xr,'final.wav');
h = wavread('final.wav');
new=max(abs(xc));
xc=(1/new)*xc;
j=audioplayer(h,48000);
play(j);

Answers (0)

Categories

Find more on Simulation, Tuning, and Visualization in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!