Ejemplo n.º 1
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") )
Ejemplo n.º 2
0
    def testMix(self):
        acmodel1 = AcModel()
        hmm1 = HMM()
        hmm1.create_proto( 25 )
        hmm1.name = "y"
        acmodel1.append_hmm( hmm1 )
        acmodel1.repllist.add("y","j")

        acmodel2 = AcModel()
        hmm2 = HMM()
        hmm2.create_proto( 25 )
        hmm2.name = "j"
        hmm3 = HMM()
        hmm3.create_proto( 25 )
        hmm3.name = "y"
        acmodel2.hmms.append( hmm2 )
        acmodel2.hmms.append( hmm3 )
        acmodel2.repllist.add("y","y")
        acmodel2.repllist.add("j","j")

        modelmixer = ModelMixer()
        modelmixer.set_models( acmodel1,acmodel2 )

        outputdir = os.path.join(MODELDIR, "models-test")
        modelmixer.mix( outputdir, gamma=1. )
        mixedh1 = AcModel()
        mixedh1.load( outputdir )
        shutil.rmtree( outputdir )