Exemplo n.º 1
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 )
Exemplo n.º 2
0
    def test_monophones(self):
        acmodel1 = AcModel()
        acmodel1.load( os.path.join(MODEL_PATH,"models-fra") )

        acmodel2 = acmodel1.extract_monophones()
        acmodel2.save(os.path.join(HERE,'fra-mono'))
        self.assertTrue(  os.path.isfile( os.path.join(HERE, 'fra-mono','hmmdefs')) )
        self.assertTrue(  os.path.isfile( os.path.join(HERE, 'fra-mono','monophones.repl')) )
        self.assertFalse( os.path.isfile( os.path.join(HERE, 'fra-mono','tiedlist')) )
        os.remove( os.path.join(HERE, 'fra-mono','hmmdefs') )
        os.remove( os.path.join(HERE, 'fra-mono','monophones.repl') )
        os.rmdir( os.path.join(HERE,'fra-mono') )
        self.assertEqual( len(acmodel2.hmms), 38 )
Exemplo n.º 3
0
    def test_replace_phones(self):
        acmodel1 = AcModel()
        acmodel1.load( os.path.join(MODEL_PATH,"models-fra") )
        acmodel1.replace_phones( reverse=False )
        acmodel1.replace_phones( reverse=True )

        acmodel2 = AcModel()
        acmodel2.load( os.path.join(MODEL_PATH,"models-fra") )

        for h1 in acmodel1.hmms:
            h2 = acmodel2.get_hmm( h1.name )
            self.assertTrue(compare(h1.definition['transition'],h2.definition['transition']))
            self.assertTrue(compare(h1.definition['states'],h2.definition['states']))
Exemplo n.º 4
0
    def load(self, modelTextDir, modelSpkDir):
        """
        Load the acoustic models from their directories.

        @param modelTextDir (str)
        @param modelSpkDir (str)

        """
        modelText = AcModel()
        modelSpk  = AcModel()

        # Load the acoustic models.
        modelText.load( modelTextDir )
        modelSpk.load( modelSpkDir )

        self.set_models(modelText, modelSpk)
Exemplo n.º 5
0

if len(sys.argv) <= 1:
    sys.argv.append('-h')

args = parser.parse_args()

# ----------------------------------------------------------------------------

if not args.quiet is True:
    print "Loading AC 1:",
acmodel1 = AcModel()
if os.path.isfile( args.i ):
    acmodel1.load_htk( args.i )
else:
    acmodel1.load( args.i )
if not args.quiet is True:
    print "... done"

if not args.quiet is True:
    print "Loading AC 2:",
acmodel2 = AcModel()
if os.path.isfile( args.I ):
    acmodel2.load_htk( args.I )
else:
    acmodel2.load( args.I )
if not args.quiet is True:
    print "... done"

(appended,interpolated,keeped,changed) = acmodel1.merge_model(acmodel2,gamma=args.g)
if not args.quiet is True: