Estimation of Pitch from Speech Signals Using Autocorrelation Algorithm
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Mathieu NOE
el 10 de Mayo de 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 comentarios
Vanya Meegan
el 21 de Mayo de 2022
error unrecognized function or variable nume1
Mathieu NOE
el 23 de Mayo de 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)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!