Onyx logo

Previous topic

HTK Files

Next topic

onyx.htkfiles.htklex – Read HTK lexicon files into our lexicon structure

This Page

onyx.htkfiles.htkmmf – Read HTK mmf files into our model structure.

>>> module_dir, module_name = os.path.split(__file__)
>>> filename = os.path.join(module_dir, "start.mmf")
>>> with open(filename) as f:
...     models_dict, hmm_mgr, gmm_mgr = read_htk_mmf_file(f)
>>> print sorted(models_dict)
['class1', 'class2', 'class3']
>>> print gmm_mgr
GmmMgr with 3 models of type <class 'onyx.am.gaussian.GaussianMixtureModel'>
  (dimension 2, covariance_type onyx.am.gaussian.GaussianModelBase.DIAGONAL_COVARIANCE)
>>> for name, index in models_dict.items():
...     print "Built model %s at index %d:" % (name,index)
...     print hmm_mgr[index].to_string()
Built model class2 at index 1:
Hmm: num_states = 1, log_domain = False, model dim = 2
Built model class3 at index 2:
Hmm: num_states = 1, log_domain = False, model dim = 2
Built model class1 at index 0:
Hmm: num_states = 1, log_domain = False, model dim = 2
>>> filename = os.path.join(module_dir, "monophones.mmf")
>>> with open(filename) as f:
...     models_dict, hmm_mgr, gmm_mgr = read_htk_mmf_file(f)
>>> print ' '.join(sorted(models_dict))
aa ae ah ao aw ax ay b ch d dd dh dx eh el en er ey f g hh ih iy jh k kd l m n ng ow oy p pd r s sh sil sp t td th ts uh uw v w y z
>>> print gmm_mgr
GmmMgr with 145 models of type <class 'onyx.am.gaussian.GaussianMixtureModel'>
  (dimension 39, covariance_type onyx.am.gaussian.GaussianModelBase.DIAGONAL_COVARIANCE)
onyx.htkfiles.htkmmf.logreftest()
onyx.htkfiles.htkmmf.read_htk_mmf_file(file, log_domain=False)

Read HTK mmf files into our model structure.

file should be a filestream opened on an HTK MMF file. hmm_mgr and gmm_mgr must be HmmMgr and GmmMgr instances, respectivly, and both must be in the NOT_ADAPTING state. The return is a dict with the names of the models as keys and the model indices in hmm_mgr as values.