diff experiments/scripts/cnbh-syllables/run_training_and_testing/gen_hhed_script.py @ 84:bee31e7ebf4b

- Added as-yet-unfinished support for a proper configuraiton file format - Added a couple of pythin scripts to generate HMM configuration files - Variable name changes and other cosmetic things - Added the option for the noise generation to do pink noise (untested)
author tomwalters
date Thu, 12 Aug 2010 11:28:11 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/experiments/scripts/cnbh-syllables/run_training_and_testing/gen_hhed_script.py	Thu Aug 12 11:28:11 2010 +0000
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# encoding: utf-8
+"""
+gen_hhed_script.py
+
+Created by Thomas Walters on 2010-07-08.
+"""
+
+import sys
+import getopt
+
+
+help_message = '''
+Generate an HTK HHed script to change the number of means in the output
+distribution to num_means for the emitting states of an HMM with
+total_hmm_states states
+'''
+
+
+class Usage(Exception):
+  def __init__(self, msg):
+    self.msg = msg
+
+
+def main(argv=None):
+  if argv is None:
+    argv = sys.argv
+  try:
+    try:
+      opts, args = getopt.getopt(argv[1:], "hn:s:v", ["help", "num_means=", "total_hmm_states="])
+    except getopt.error, msg:
+      raise Usage(msg)
+  
+    # defaults
+    num_means = 3
+    total_hmm_states = 6
+    
+    # option processing
+    for option, value in opts:
+      if option == "-v":
+        verbose = True
+      if option in ("-h", "--help"):
+        raise Usage(help_message)
+      if option in ("-n", "--num_means"):
+        num_means = int(value)
+      if option in ("-s", "--total_hmm_states"):
+        total_hmm_states = int(value)
+  
+  except Usage, err:
+    print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg)
+    print >> sys.stderr, "\t for help use --help"
+    return 2
+
+  out_string = ""
+  for state in xrange(2, total_hmm_states):
+    out_string += ("MU " + str(num_means) + " {*.state[" + str(state) + "].mix} ")
+  print out_string
+
+if __name__ == "__main__":
+  sys.exit(main())
\ No newline at end of file