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)
Show older comments
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);
2 Comments
Walter Roberson
on 17 Apr 2014
Edited: Walter Roberson
on 17 Apr 2014
Please show the exact error message and the traceback (chain of calls to get there)
Note: you probably want
wavwrite(xr, fs, 'final.wav')
as otherwise it will be written at 6000 Hz.
Answers (0)
See Also
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!