added some tests for est_n0, working OK for basic impulse case

master
David 2019-12-04 14:26:24 +10:30
parent 9ab6a221dc
commit 4f8c7ea4fb
4 changed files with 41 additions and 5 deletions

View File

@ -102,9 +102,9 @@ for i in range(nb_samples):
alpha2 = alpha1 + 0.4*np.pi*r2[0]
gamma2 = 0.9 + 0.05*r2[1]
else:
alpha1 = 0.5*np.pi + 0.9*np.pi*r1[0]
alpha1 = 0.5*np.pi + 0.4*np.pi*r1[0]
gamma1 = 0.8 + 0.1*r1[1]
alpha2 = 0.5*np.pi + 0.9*np.pi*r2[0]
alpha2 = 0.5*np.pi + 0.4*np.pi*r2[0]
gamma2 = 0.8 + 0.1*r2[1]
w1,h1 = signal.freqz(1, [1, -2*gamma1*np.cos(alpha1), gamma1*gamma1], range(1,L[i]+1)*Wo[i])

View File

@ -36,7 +36,9 @@ nb_samples = Wo.size;
amp = 20.0*np.log10(A+1E-6)
# read in n0 estimates
n0_est = np.loadtxt(sys.argv[2])
print(n0_est[:20])
print(Wo[:20])
print("removing linear phase component....")
phase_n0_removed = np.zeros((nb_samples, width))
for i in range(nb_samples):
@ -58,7 +60,7 @@ def sample_time(r):
s = np.zeros(2*N);
for m in range(1,L[r]+1):
s = s + A[r,m]*np.cos(m*Wo[r]*range(2*N) + phase[r,m])
s = s + A[r,m]*np.cos(m*Wo[r]*range(-N,N) + phase[r,m])
return s
plot_en = 1;
@ -89,9 +91,10 @@ if plot_en:
plt.subplot(3,4,r+1)
f = frame[r];
s = sample_time(f)
plt.plot(s,'g')
plt.plot(range(-N,N),s,'g')
mx = np.max(np.abs(s))
plt.plot([n0_est[f],n0_est[f]], [-mx/2,mx/2],'b')
print(r,f,n0_est[f])
plt.plot([-n0_est[f],-n0_est[f]], [-mx/2,mx/2],'b')
plt.show(block=False)
# click on last figure to close all and finish

18
run_n0_est.sh 100755
View File

@ -0,0 +1,18 @@
#!/bin/bash -x
# David Dec 2019
#
PATH=$PATH:~/codec2/build_linux/src:~/codec2/build_linux/misc
if [ "$#" -ne 1 ]; then
echo "usage: ./run_n0_est.sh rawFile"
fi
speech=$1
x=$(basename $speech)
base="${x%.*}"
c2sim $speech --modelout $base'.model'
cat $base.model | est_n0 > $base'_n0.txt'
./plot_n0.py $base'.model' $base'_n0.txt'

15
test_n0_est.sh 100755
View File

@ -0,0 +1,15 @@
#!/bin/bash -x
# David Dec 2019
#
PATH=$PATH:~/codec2/build_linux/src:~/codec2/build_linux/misc
if [ "$#" -ne 1 ]; then
n0=1
else
n0=$1
fi
timpulse 190 $n0 | c2sim - --modelout imp.model
cat imp.model | est_n0 > imp_n0.txt
./plot_n0.py imp.model imp_n0.txt