Estimation of Pitch from Speech Signals Using Autocorrelation Algorithm

19 vues (au cours des 30 derniers jours)
JAMES SMITH
JAMES SMITH le 4 Jan 2018
Commenté : Mathieu NOE le 23 Mai 2022
Hello,
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.
  2 commentaires
Samia Dilbar
Samia Dilbar le 14 Déc 2021
Hey did you resolve it ? help me in this
Nene Pfupa
Nene Pfupa le 10 Mai 2022
did you find the answer.help me too.

Connectez-vous pour commenter.

Réponses (1)

Mathieu NOE
Mathieu NOE le 10 Mai 2022
hello
this is a modified version of the code . The autocorrelation ouput will have a major peak at sample = M (x axis) and is symmetrical around this value. So first modification is to keep the autocor vector second half only, starting at sample = M ; what we are looking for is the next peak to get the pitch value
[y,Fs]=audioread('Sample1.wav');
y=y(:,1);
auto_corr_y=xcorr(y);
M = length(y);
% C = XCORR(A), where A is a length M vector, returns the length 2*M-1
% auto-correlation sequence C. The zeroth lag of the output correlation
% is in the middle of the sequence, at element M.
auto_corr_y = auto_corr_y(M:M+100); % keep only the second half (starting at sample = M which is the max peak output) and show + 100 samples
auto_corr_x = 1:numel(auto_corr_y);
[pks,locs] = findpeaks(auto_corr_y);
subplot(2,1,1),plot(y)
subplot(2,1,2),plot(auto_corr_x,auto_corr_y,locs,pks,'dr')
pitch_Hz=Fs/locs(1)
  2 commentaires
Vanya Meegan
Vanya Meegan le 21 Mai 2022
error unrecognized function or variable nume1
Mathieu NOE
Mathieu NOE le 23 Mai 2022
hello
numel was introduced quite recently
you can replace it with length for older matlab releases.
[y,Fs]=audioread('Sample1.wav');
y=y(:,1);
auto_corr_y=xcorr(y);
M = length(y);
% C = XCORR(A), where A is a length M vector, returns the length 2*M-1
% auto-correlation sequence C. The zeroth lag of the output correlation
% is in the middle of the sequence, at element M.
auto_corr_y = auto_corr_y(M:M+100); % keep only the second half (starting at sample = M which is the max peak output) and show + 100 samples
auto_corr_x = 1:length(auto_corr_y);
[pks,locs] = findpeaks(auto_corr_y);
subplot(2,1,1),plot(y)
subplot(2,1,2),plot(auto_corr_x,auto_corr_y,locs,pks,'dr')
pitch_Hz=Fs/locs(1)

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by