0
$\begingroup$

I want to get frequencies from amplitudes and I'm following Chap 5.1.1 from Speech Signal Processing by Praat Apply window function and find autocorrelation
As the in pictures, I will multiply the signal $s(t)$ with the Hanning window $w(t)$, find its normalized autocorrelation $r_a(\tau)$, and divide by $r_w(\tau)$, which is the normalized autocorrelation of $w(t)$. In the end, I will get the corrected autocorrelations $r(\tau)$.
I understand that diving $r_w$ should somehow rescale $r_a$, but the $r_w$ I got takes negative value, and $r$ gets large where $r_w$ is close to zero. How can I get an $r_w$ as in the picture?

Below are my codes to get $r_w$:

def serial_cov(wave:List[int], lag:int)  -> int:
"""
Returns covariance of a signal with a lagged version of itself
"""
global WINDOW_LEN
n=len(wave)
y1=wave[lag:]
y2=wave[0:WINDOW_LEN - lag]
num = float(np.cov(y1,y2,bias=True)[0,1])   
return num

hann = np.hanning(WINDOW_LEN) 
plt.plot(hann) 
plt.title("Hann window amplitude") 
plt.show() 
r0_hann = float(np.cov(hann, hann, bias = True)[0,0])
hann_autocorr = []
for i in range(MAX_LAG+1):
    ri_hann = serial_cov(hann,i)
    hann_autocorr.append(ri_hann/r0_hann)
New contributor
yrq is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$

Your Answer

yrq is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.