annotate experiments/scripts/cnbh-syllables/run_training_and_testing/gen_hhed_script.py @ 626:586b0677aae8
Fourth revision of Alex Brandmeyer's C++ implementation. Fixed more style issues, changed AGC structures to vectors, replaced FloatArray2d with vector<FloatArray>, implemented first tests using GTest to verify coefficients and monaural output against Matlab values (stored in aimc/carfac/test_data/). To run tests, change the path stored in carfac_test.h in TEST_SRC_DIR. Added CARFAC_GenerateTestData to the Matlab branch, fixed stage indexing in CARFAC_Cross_Couple.m to reflect changes in AGCCoeffs and AGCState structs.
author |
alexbrandmeyer |
date |
Wed, 22 May 2013 21:30:02 +0000 |
parents |
bee31e7ebf4b |
children |
|
rev |
line source |
tomwalters@84
|
1 #!/usr/bin/env python
|
tomwalters@84
|
2 # encoding: utf-8
|
tomwalters@84
|
3 """
|
tomwalters@84
|
4 gen_hhed_script.py
|
tomwalters@84
|
5
|
tomwalters@84
|
6 Created by Thomas Walters on 2010-07-08.
|
tomwalters@84
|
7 """
|
tomwalters@84
|
8
|
tomwalters@84
|
9 import sys
|
tomwalters@84
|
10 import getopt
|
tomwalters@84
|
11
|
tomwalters@84
|
12
|
tomwalters@84
|
13 help_message = '''
|
tomwalters@84
|
14 Generate an HTK HHed script to change the number of means in the output
|
tomwalters@84
|
15 distribution to num_means for the emitting states of an HMM with
|
tomwalters@84
|
16 total_hmm_states states
|
tomwalters@84
|
17 '''
|
tomwalters@84
|
18
|
tomwalters@84
|
19
|
tomwalters@84
|
20 class Usage(Exception):
|
tomwalters@84
|
21 def __init__(self, msg):
|
tomwalters@84
|
22 self.msg = msg
|
tomwalters@84
|
23
|
tomwalters@84
|
24
|
tomwalters@84
|
25 def main(argv=None):
|
tomwalters@84
|
26 if argv is None:
|
tomwalters@84
|
27 argv = sys.argv
|
tomwalters@84
|
28 try:
|
tomwalters@84
|
29 try:
|
tomwalters@84
|
30 opts, args = getopt.getopt(argv[1:], "hn:s:v", ["help", "num_means=", "total_hmm_states="])
|
tomwalters@84
|
31 except getopt.error, msg:
|
tomwalters@84
|
32 raise Usage(msg)
|
tomwalters@84
|
33
|
tomwalters@84
|
34 # defaults
|
tomwalters@84
|
35 num_means = 3
|
tomwalters@84
|
36 total_hmm_states = 6
|
tomwalters@84
|
37
|
tomwalters@84
|
38 # option processing
|
tomwalters@84
|
39 for option, value in opts:
|
tomwalters@84
|
40 if option == "-v":
|
tomwalters@84
|
41 verbose = True
|
tomwalters@84
|
42 if option in ("-h", "--help"):
|
tomwalters@84
|
43 raise Usage(help_message)
|
tomwalters@84
|
44 if option in ("-n", "--num_means"):
|
tomwalters@84
|
45 num_means = int(value)
|
tomwalters@84
|
46 if option in ("-s", "--total_hmm_states"):
|
tomwalters@84
|
47 total_hmm_states = int(value)
|
tomwalters@84
|
48
|
tomwalters@84
|
49 except Usage, err:
|
tomwalters@84
|
50 print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg)
|
tomwalters@84
|
51 print >> sys.stderr, "\t for help use --help"
|
tomwalters@84
|
52 return 2
|
tomwalters@84
|
53
|
tomwalters@84
|
54 out_string = ""
|
tomwalters@84
|
55 for state in xrange(2, total_hmm_states):
|
tomwalters@84
|
56 out_string += ("MU " + str(num_means) + " {*.state[" + str(state) + "].mix} ")
|
tomwalters@84
|
57 print out_string
|
tomwalters@84
|
58
|
tomwalters@84
|
59 if __name__ == "__main__":
|
tomwalters@84
|
60 sys.exit(main()) |