Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi all
I want to run my code that is about Speech Enhancement Based on Deep Neural Networks and our steps are

1-framing signal * hamming window
2-log-power spectral frame
3-Deep learning
4-inverse output to signal

So my problem is inversing can not return true answer my code

VB
function [ out ] = dfft( s )


 N=300;
 M=20;
 L=length(s);

 NumFram=floor(L/(N-M))-1;
 frames=zeros(NumFram,N);
 for i=1:N

 frames(1,i)=s(i);

 end
 j=1;


 for j=2:NumFram
 n=1;

 for i= (j-1) * (N-M) : (j-1) * (N-M) + N

 frames(j,n)=s(i);
 n=n+1;


 end
 end

 frames(:,N+1)=[];


 HamiW=zeros(1,N);
 HamW=hamming(N);

for i=1:N
HamiW(1,i)=HamW(i);
end


Y=zeros(NumFram,N);

Y=frames*diag(HamiW);

 FFT=zeros(NumFram,N);


 for i=1:NumFram

 FFT(i,:)=fft(Y(i,:));
 for j=1:N
 phase(i,j)=atan(imag(FFT(i,j))/real(FFT(i,j)));
 logfft(i,j)=FFT(i,j)*conj(FFT(i,j));
 Z=sqrt(logfft(i,j));
 S(i,j)= complex(Z*cos(phase(i,j)),Z*sin(phase(i,j)));


 end
out(i,:)=ifft(S(i,:));

end
Posted
Updated 30-Jul-15 3:27am
v3
Comments
Kenneth Haugland 26-Jul-15 7:52am    
Usually the power spectrum is 20*log10(abs(FFT)), you seem to favor the natural logarithm? In any cast that is just for viewing the spectrum.

I don't know what you mean by inverse the signal, if it is back to its original you need to perform an ifft of the fft.
Sa.Mo 30-Jul-15 9:28am    
can u check my update code? thanks
Sergey Alexandrovich Kryukov 27-Jul-15 0:36am    
Multiply the signal by −1...
—SA
Sa.Mo 31-Jul-15 8:02am    
was not work..

1 solution

You seem to lack some knowledge on DSP (Digital Signal Prepossessing) so I would suggest you start reading some books or online material to gain some background information on what you are working with here.

Normally we take the Hamming[^], Blackman or some other window function to filter input signal with voice in it. It is basically a specialty designed filter. And it is normally used together with convolution of signals[^].
If memory serves me correctly it was used the following way (assumeing that f(t) is the time dependent signal and Ham(t) is the Hamming window):
C#
output = conv(f,Ham);


Once you have your output signal you can take the fft of it to get the spectrum. It is normal to take the log of the signal to get more human readable signal.To plot it together with a frequency you need to know the sample rate as well. Taken form this[^]:
C++
nf=1024; %number of point in DTFT   
Y = fft(y,nf);    
f = fs/2*linspace(0,1,nf/2+1);    
plot(f,log(1 + abs(Y(1:nf/2+1)))); %// Change    
title('Single-Sided Amplitude Spectrum of y(t)')   
xlabel('Frequency (Hz)')   
ylabel('|Y(f)|') 


Now to understand what you do when you actually take an fft of a signal, that you transform it to the frequency domain from the time domain. You can also go the other way from the frequency domain to the time domain with an ifft. However some information is lost on the way, so what you get is the Impulse Response, and not the original signal. So information got lost on the way.
 
Share this answer
 
Comments
RedDk 30-Jul-15 15:00pm    
Hear hear.
ISBN 0-13-179144-3 ... Embree&Danieli "C++ Algorithms For Digital Signal Processing".
Kenneth Haugland 30-Jul-15 21:41pm    
Haven't gotten that book, but I do have this one:
http://www.amazon.com/Scientist-Engineers-Digital-Signal-Processing/dp/0966017633/ref=pd_sim_sbs_14_7?ie=UTF8&refRID=0KVEGCH2T0VDZV7PYPC8
Sa.Mo 31-Jul-15 8:06am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900