Estimation of Pitch from Speech Signals Using Autocorrelation Algorithm
조회 수: 29 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Mathieu NOE
2022년 5월 10일
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
Mathieu NOE
2022년 5월 23일
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)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!