コード例 #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):
     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
コード例 #3
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
コード例 #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