0

I want to detect speech signals pitch frequency using autocorrelation algorithm. I have a MATLAB code but the results are wrong. I would be grateful if you could solve the mistake in my code.

[y,Fs]=audioread('Sample1.wav'); 
y=y(:,1);
auto_corr_y=xcorr(y); 
subplot(2,1,1);plot(y) 
subplot(2,1,2);plot(auto_corr_y)
[pks,locs] = findpeaks(auto_corr_y);
[mm,peak1_ind]=max(pks);
period=locs(peak1_ind+1)-locs(peak1_ind);
pitch_Hz=Fs/period

Thank you for your help in this matter.

  • 1
    Why are the results wrong? What did you get? What did you expect? – Cris Luengo Jan 05 '18 at 06:46
  • I want to detect the pitch of speaker's voice. But it results over the human frequency limits. –  JAMES SMITH Jan 05 '18 at 07:51
  • `findpeaks` might be finding too many peaks. Did you plot the peaks it finds? Do they look correct? `hold on; plot(locs,pks,'o')`. – Cris Luengo Jan 05 '18 at 14:13
  • I once wrote a little paper on this topic. There are many pre-processing and post-processing that needs to be done to get more accuracy with auto-correlation method. It also fails when there are multiple tones in the signal. You can browse the source and paper here: http://shafq.at/papers/pda_paper_ayan.pdf – Ayan Shafqat Jan 05 '18 at 17:14

1 Answers1

1

Seems, your code do not works because the Sample1.wav must contains only the short quazi-periodic part of the vocalized record. Also note, the pitch frequency is not the constant over time, so your estimation must takes this into account.

If you just want to estimate the frequency, you can take the RAPT method from the Speech Filling System (see the sfs_rapt.m wrapper for Windows).

Andrei Davydov
  • 315
  • 1
  • 7