#!/usr/bin/python
# build_hmmdefs.py 1/16/08 Ilana Heintz
# take in the single mean and variance hmm in hmm0
# repeat it for each monophone in the list
# store in a file named hmmdefs
import os, sys
def printHMM(phone, hmm, outfile):
"""
print the hmm again, labeling it with this phone
"""
hmm[3] = '~h "%s"' % phone.rstrip()
for item in hmm:
print >> outfile, item.rstrip()
if __name__ == '__main__':
if len(sys.argv) < 3:
print "Usage: build_hmmdefs.py phonefile hmmfile"
phonefile = open(sys.argv[1],'r')
phones = phonefile.readlines()
phonefile.close()
hmmfile = open(sys.argv[2],'r')
hmm = hmmfile.readlines()
hmmfile.close()
outfile = open('hmm0/hmmdefs','w')
for ph in phones:
printHMM(ph, hmm, outfile)
outfile.close()