[Solved]Function Extract Pitch Information Speech Files Pitch Obtained Calculating Peak Autocorrel Q37075839

% Function:
% Extract pitch information from speech files.
% Pitch can be obtained by calculating the peak ofautocorrelation
% Usually the original speech file is segmented into frames
% and pitch contour can be derived by plotting of the peaksfrom
% each frame
%
% Input:
% x: original speech
% fs: sampling rate
%
% Output:
% t: time frame
% f0: pitch contour
% avgF0: average pitch frequency
%
% Acknowledgement:
% this code is based on Philipos C. Loizou’s colea Copyright (c)1995
%
function [t, f0, avgF0] = pitch(x, fs)
% get the number of samples
ns = length(x);
% error checking on the signal level, remove the DC bias
mu = mean(x);
x = x – mu;
% use a 30msec segment, choose a segment every 20msec
% that means the overlap between segments is 10msec
fRate = floor(120*fs/1000);
updRate = floor(110*fs/1000);
nFrames = floor(ns/updRate)-1;
% the pitch contour is then a 1 x nFrames vector
f0 = zeros(1, nFrames);
f01 = zeros(1, nFrames);
% get the pitch from each segmented frame
k = 1;
avgF0 = 0;
m = 1;
for i=1:nFrames
xseg = x(k:k+fRate-1);
f01(i) = pitchacorr(fRate, fs, xseg);
% do some median filtering, less affected by noise
if i>2 & nFrames>3
z = f01(i-2:i);
md = median(z);
f0(i-2) = md;
if md > 0
avgF0 = avgF0 + md;
m = m + 1;
end
elseif nFrames<=3
f0(i) = a;
avgF0 = avgF0 + a;
m = m + 1;
end
k = k + updRate;
end
t = 1:nFrames;
t = 20 * t;
if m==1
avgF0 = 0;
else
avgF0 = avgF0/(m-1);
end
% Pitch estimation using the autocorrelation method
% Modified based on colea Copyright (c) 1995 Philipos C.Loizou
%
function [f0] = pitchacorr(len, fs, xseg)
% LPF at 900Hz
[bf0, af0] = butter(4, 900/(fs/2));
xseg = filter(bf0, af0, xseg);
% find the clipping level, CL
i13 = len/3;
maxi1 = max(abs(xseg(1:i13)));
i23 = 2 * len/3;
maxi2 = max(abs(xseg(i23:len)));
if maxi1>maxi2
CL=0.68*maxi2;
else
CL= 0.68*maxi1;
end
% Center clip waveform, and compute the autocorrelation
clip = zeros(len,1);
ind1 = find(xseg>=CL);
clip(ind1) = xseg(ind1) – CL;
ind2 = find(xseg <= -CL);
clip(ind2) = xseg(ind2)+CL;
engy = norm(clip,2)^2;
RR = xcorr(clip);
m = len;
% Find the max autocorrelation in the range 60 <= f <= 320Hz
LF = floor(fs/320);
HF = floor(fs/60);
Rxx = abs(RR(m+LF:m+HF));
[rmax, imax] = max(Rxx);
imax = imax + LF;
f0 = fs/imax;
% Check max RR against V/UV threshold
silence = 0.4*engy;
if (rmax > silence) & (f0 > 60) & (f0 <=320)
f0 = fs/imax;
else % — its unvoiced segment ———
f0 = 0;
end
3. (30 pts) Pitch analysis. Pitch can be derived using autocorrelation, Cepstrum analysis, etc. Pitch characterizes the peak energy levels of the signal. Here is the function to derive pitch contour http://web.eecs.utk.edu/ -qi/ece315/project/pitch.mpitch.m. Go through the code and un- derstand how the contour is generated. Explain in the report how to calcu late autocorrelation and how the code generates pitch contour. Plot the pitch contour of all your 4 recorded speeches with the course title. Do they look similar? Pick a speech file from a classmate and plot the pitch contour. Do they look similar or very different? Here is the http://web.eecs.utk. edu/-qi/ece315/project/pitchacorr.mpitchacorrO function called by pitch () Show transcribed image text 3. (30 pts) Pitch analysis. Pitch can be derived using autocorrelation, Cepstrum analysis, etc. Pitch characterizes the peak energy levels of the signal. Here is the function to derive pitch contour http://web.eecs.utk.edu/ -qi/ece315/project/pitch.mpitch.m. Go through the code and un- derstand how the contour is generated. Explain in the report how to calcu late autocorrelation and how the code generates pitch contour. Plot the pitch contour of all your 4 recorded speeches with the course title. Do they look similar? Pick a speech file from a classmate and plot the pitch contour. Do they look similar or very different? Here is the http://web.eecs.utk. edu/-qi/ece315/project/pitchacorr.mpitchacorrO function called by pitch ()
Expert Answer
Answer to % Function: % Extract pitch information from speech files. % Pitch can be obtained by calculating the peak of autocorre… . . .
OR

