So I'm currently working on a code for linear prediction, where we apply the various concepts of linear prediction into a raw audio signal In this code I have m as the len of the audio that i inputted, now I get this error here when I try to code the frequency response of it:
omega = np.pi*m
x_real = np.zeros(m)
x_imaj = np.zeros(m)
for i in range(0, int(m/2)):
for j in range(1, t_lag):
x_real[i] += inv_a[j]*np.cos(j*omega[i])
x_imaj[i] += inv_a[j]*np.sin(j*omega[i])
x_real[i] = 1-x_real[i]
H_2 = 1/np.sqrt(x_real**2+x_imaj**2)
#Frequency Response for Linear Prediction
h_real = np.zeros(m)
h_imaj = np.zeros(m)
for i in range(0, int(m/2)):
for j in range(1, t_lag):
h_real[i] += a[j]*np.cos(j*omega[i])
h_imaj[i] += a[j]*np.sin(j*omega[i])
h_real[i] = 1-h_real[i]
H_1 = 1/np.sqrt(h_real**2+h_imaj**2)
#Plotting Frequency Response
fig, ax = plt.subplots(figsize=(40,20))
ax.plot(H_1, color='red', label='A Omega')
ax.plot(H_2, color='blue', label='H Omega')
ax.set_title("Response Frequency",font="times new roman", size=55)
ax5.set_xlabel('Ohm', fontsize='x-small')
ax5.set_ylabel('Magnitude', fontsize='x-small')
fig.tight_layout()
ax.legend(fontsize=50)
plt.show()
and the error that i receive is:
TypeError Traceback (most recent call last)
c:\Users\Armand S\Desktop\Python Biomodelling File\[FP BIOMOD]Linear Prediction_Armand Faris A Surbakti_5023201051.ipynb Cell 12 in <cell line: 8>()
8 for i in range(0, int(m/2)):
9 for j in range(1, t_lag):
---> 10 x_real[i] += inv_a[j]*np.cos(j*omega[i])
11 x_imaj[i] += inv_a[j]*np.sin(j*omega[i])
13 x_real[i] = 1-x_real[i]
TypeError: 'float' object is not subscriptable
Which is a typeerror
Any help of this would be appreciated!