Пример #1
0
 def test_forward_backward(self):
     mfcc = s2mfc.open(os.path.join(self.testdir, 'man.ah.111a.mfc')).getall()
     mfcc -= mfcc.mean(0)
     feat = _1s_c_d_dd.compute(mfcc)
     hg = hmm.HMMGraph(self.factory.create('SIL'),
                       self.factory.create('SIL'))
     alpha = None
     self.alpha = []
     for f in feat[0:15]:
         senscr = self.acmod.senone_compute(hg.iter_senones(), f)
         alpha = hmm.forward_evaluate(hg, senscr, alpha)
         self.alpha.append(alpha)
     beta = None
     self.beta = []
     for f in feat[15:0:-1]: # Note that this is time-shifted by
                             # one from the forward pass above
         senscr = self.acmod.senone_compute(hg.iter_senones(), f)
         beta = hmm.backward_evaluate(hg, senscr, beta)
         self.beta.append(beta)
     self.beta.reverse()
     ll = 0
     for a,b in zip(self.alpha, self.beta):
         newll = sum(a*b)
         if ll != 0:
             self.assert_(abs(log(ll) - log(newll)) < 0.1)
         ll = newll
Пример #2
0
 def test_forward_backward(self):
     pid = self.acmod.mdef.phone_id('SIL')
     h1 = hmm.HMM(self.acmod.mdef.pid2sseq(pid),
                  self.acmod.tmat[self.acmod.mdef.pid2tmat(pid)])
     mfcc = s2mfc.open(os.path.join(self.testdir, 'man.ah.111a.mfc')).getall()
     mfcc -= mfcc.mean(0)
     feat = _1s_c_d_dd.compute(mfcc)
     alpha = None
     self.alpha = []
     for f in feat[0:50]:
         senscr = self.acmod.senone_compute(h1.iter_senones(), f)
         alpha = hmm.forward_evaluate(h1, senscr, alpha)
         self.alpha.append(alpha)
     beta = None
     self.beta = []
     for f in feat[50:0:-1]: # Note that this is time-shifted by
                             # one from the forward pass above
         senscr = self.acmod.senone_compute(h1.iter_senones(), f)
         beta = hmm.backward_evaluate(h1, senscr, beta)
         self.beta.append(beta)
     self.beta.reverse()
     ll = 0
     for a,b in zip(self.alpha, self.beta):
         newll = sum(a*b)
         if ll != 0:
             self.assert_(abs(log(ll) - log(newll)) < 0.1)
         ll = newll
Пример #3
0
 def test_forward_backward(self):
     mfcc = s2mfc.open(os.path.join(self.testdir,
                                    'man.ah.111a.mfc')).getall()
     mfcc -= mfcc.mean(0)
     feat = _1s_c_d_dd.compute(mfcc)
     hg = hmm.HMMGraph(self.factory.create('SIL'),
                       self.factory.create('SIL'))
     alpha = None
     self.alpha = []
     for f in feat[0:15]:
         senscr = self.acmod.senone_compute(hg.iter_senones(), f)
         alpha = hmm.forward_evaluate(hg, senscr, alpha)
         self.alpha.append(alpha)
     beta = None
     self.beta = []
     for f in feat[15:0:-1]:  # Note that this is time-shifted by
         # one from the forward pass above
         senscr = self.acmod.senone_compute(hg.iter_senones(), f)
         beta = hmm.backward_evaluate(hg, senscr, beta)
         self.beta.append(beta)
     self.beta.reverse()
     ll = 0
     for a, b in zip(self.alpha, self.beta):
         newll = sum(a * b)
         if ll != 0:
             self.assert_(abs(log(ll) - log(newll)) < 0.1)
         ll = newll
Пример #4
0
 def test_forward_backward(self):
     pid = self.acmod.mdef.phone_id('SIL')
     h1 = hmm.HMM(self.acmod.mdef.pid2sseq(pid),
                  self.acmod.tmat[self.acmod.mdef.pid2tmat(pid)])
     mfcc = s2mfc.open(os.path.join(self.testdir,
                                    'man.ah.111a.mfc')).getall()
     mfcc -= mfcc.mean(0)
     feat = _1s_c_d_dd.compute(mfcc)
     alpha = None
     self.alpha = []
     for f in feat[0:50]:
         senscr = self.acmod.senone_compute(h1.iter_senones(), f)
         alpha = hmm.forward_evaluate(h1, senscr, alpha)
         self.alpha.append(alpha)
     beta = None
     self.beta = []
     for f in feat[50:0:-1]:  # Note that this is time-shifted by
         # one from the forward pass above
         senscr = self.acmod.senone_compute(h1.iter_senones(), f)
         beta = hmm.backward_evaluate(h1, senscr, beta)
         self.beta.append(beta)
     self.beta.reverse()
     ll = 0
     for a, b in zip(self.alpha, self.beta):
         newll = sum(a * b)
         if ll != 0:
             self.assert_(abs(log(ll) - log(newll)) < 0.1)
         ll = newll
 def test_compute(self):
     mfcc = s2mfc.open(os.path.join(self.testdir, 'man.ah.111a.mfc')).getall()
     mfcc -= mfcc.mean(0)
     feat = _1s_c_d_dd.compute(mfcc)
     senones = [0, 69, 135, 525]
     expected = [3.03518949e-36, 1.00000000e+00, 4.47046728e-16, 1.07179724e-01]
     senscr = self.acmod.senone_compute(senones, feat[0])
     for i,s in enumerate(senones):
         self.assert_(abs(senscr[s] - expected[i]) < 0.01)
Пример #6
0
 def test_compute(self):
     mfcc = s2mfc.open(os.path.join(self.testdir,
                                    'man.ah.111a.mfc')).getall()
     mfcc -= mfcc.mean(0)
     feat = _1s_c_d_dd.compute(mfcc)
     senones = [0, 69, 135, 525]
     expected = [
         3.03518949e-36, 1.00000000e+00, 4.47046728e-16, 1.07179724e-01
     ]
     senscr = self.acmod.senone_compute(senones, feat[0])
     for i, s in enumerate(senones):
         self.assert_(abs(senscr[s] - expected[i]) < 0.01)