示例#1
0
 def test_save_hmm(self):
     hmm = HMM()
     hmm.load( os.path.join(HERE,"N-hmm") )
     hmm.save(os.path.join(HERE,"N-hmm-copy"))
     newhmm = HMM()
     newhmm.load(os.path.join(HERE,"N-hmm-copy"))
     os.remove(os.path.join(HERE,'N-hmm-copy'))
     self.assertEqual(hmm.name,newhmm.name)
     self.assertTrue(compare(hmm.definition,newhmm.definition))
示例#2
0
    def test_proto(self):
        h1 = HtkIO()
        h1.write_hmm_proto( 25, os.path.join(HERE,"proto_from_htkio") )

        h2 = HMM()
        h2.create_proto( 25 )
        h2.save( os.path.join(HERE,"proto_from_hmm") )

        m1 = HMM()
        m1.load( os.path.join(HERE,"proto_from_htkio") )

        m2 = HMM()
        m2.load( os.path.join(HERE,"proto_from_hmm") )

        self.assertTrue(compare(m1.definition['transition'],m2.definition['transition']))
        self.assertTrue(compare(m1.definition['states'],m2.definition['states']))

        os.remove( os.path.join(HERE,"proto_from_hmm") )
        os.remove( os.path.join(HERE,"proto_from_htkio") )