Estimation of Pitch from Speech Signals Using Autocorrelation Algorithm

조회 수: 29 (최근 30일)
JAMES SMITH
JAMES SMITH 2018년 1월 4일
댓글: Mathieu NOE 2022년 5월 23일
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.

답변 (1개)

Mathieu NOE
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
Vanya Meegan
Vanya Meegan 2022년 5월 21일
error unrecognized function or variable nume1
Mathieu NOE
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)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by