Find Pitch in speech frame

Ali Bodaghi picture Ali Bodaghi · Feb 24, 2014 · Viewed 8.8k times · Source

I have a speech frame. when I compute the LP residual, I could not estimate the pitch truly. I need to find pitch period for each frame. However, When I use frequency domain and time domain, none of them work well. Could anyone help me? I need it for find Pitch-synchronous windowing based on pitch tracking

The result for my code is like enter image description here Thanks

The MATLAB code are as following:

    frame_length=0.03*fs;
 frame=wave1((i-1)*frame_length+1:i*frame_length);   
N=256;
Y1 = fft(frame,N);
f = 0 : fs / N : fs - 1 / N;
N1 = length(Y1); 
%Y1(1) = []; 
power1 = abs(Y1(1:floor(N1))).^2;
nyquist = 1/2;
freq1 = (1:floor(N1/2))/floor(N1/2)*nyquist;
[val loc]=max(power1);
pitch_priod = round(fs*(1./f(loc)));

or

frame=wave1((i-1)*frame_length+1:i*frame_length);   
min_pitch=floor(fs/600); % Pitch for men 50 to 300 Hz and for women 100 till 600 Hz
max_pitch=floor(fs/50);
y1=xcorr(frame);
y1=y1./(abs(max(y1)));
y2=y1(min_pitch:max_pitch);
[val loc]=max(y2);
pitch_priod=loc+min_pitch;

Answer

ederwander picture ederwander · Feb 24, 2014

We not know the size of your frame and your sampe rate, a quick look in your frequency domain code say me that are you getting 256 points from FFT, this may not be sufficient for accurate results, try split your signal in bigger frames to pass to your FFT !

For time domain the size of your frame is important too !

Here one simple autocorrelation example:

f  = 500;
Fs=8000
frame= 0.9*sin(2*pi*f/Fs*(1:4096));

X = xcorr(frame,160,'coeff'); 

X=X(160+1:2*160+1); 


[Xmax,i]=max(X(8:end));

%Period    
P = (8+i-2)

%Pitch Test, this result need be near or equal f
Fs/P

trying find pitches between 50 and 1000 hertz, I just use a pure sinusoid with frame size = 4096 to show you how can be done in time domain!