parser.add_argument('-mlfname', type=str, help="The name to prepend the output mlfs, if making mlfs.", default="txt") parser.add_argument('-slf', action="store_true", help="Output slfs.") parser.add_argument('-pronoun_variant', action="store_true", help="Create pronounciation variant slfs.") parser.add_argument('combilexpath', type=str, help="The path to the combilex dictionary directory.") args = parser.parse_args() #Used for utt creation args.intype = "txt" args.stanfordparse = False args.dictionary = dictionary.Dictionary(args.combilexpath) if args.pronoun_variant and not args.slf: print "Cannot create pronounciation variant mlfs. Please output slfs." sys.exit() txtfiles = io.load_txt_dir(args.txtdir) #Opening the mlf files here means we don't have to loop twice if outputting slfs as well. if args.mlf: #Out mlf with short pause wfsp = open(os.path.join(args.outdir, args.mlfname+"_sp.mlf"), "w") wfsp.write("#!MLF!#\n") #out mlf without short pause wfnosp = open(os.path.join(args.outdir, args.mlfname+"_no_sp.mlf"), "w") wfnosp.write("#!MLF!#\n") for txt in txtfiles: print "Processing {0}".format(txt) #Make an utt utt = utterance.Utterance(txt, args) if args.mlf:
parser.add_argument('-qpath', type=str, help="The directory to write the question set to.", default=os.path.join("questions", str(datetime.now())+".hed")) parser.add_argument('-target', type=str, help="The target type of the output labs and questions.", choices=['HMM', 'NN'], default='HMM') parser.add_argument('-stanfordparse', action="store_true", help="Add stanford parse information from parses in provided dirpath. Note this assumes you have already run txt2parse to create a parse.") parser.add_argument('-context_type', type=str, choices=['absolute', 'relational'], help="The type of positional contexts to add.", default='relational') parser.add_argument('-parsedir', type=str, help="The path to the parses.", default="parse") parser.add_argument('-HHEd_fix', action="store_true", help="Applies a fix to the contexts around the current phoneme to be compatible with hardcoded delimiters in HHEd.") args = parser.parse_args() #The phoneme set used - hardcoded as currently only combilex is possible args.phoneme_features = phoneme_features.CombilexPhonemes() if args.stanfordparse: args.parsedict = read_stanford_parses(args.parsedir) if args.intype == "txt": labs = io.load_txt_dir(args.txtdir) if args.combilexpath == None: print "No path to combilex. Please use -combilexpath option." sys.exit() args.dictionary = dictionary.Dictionary(args.combilexpath) elif args.intype == "hts_lab": labs = io.open_line_by_line(args.inpath) args.intype = "hts_mlf" else: if args.inpath == None: print "Input is mlf type but no mlf path has been set! Please use -inpath option." sys.exit() mlf = open(args.inpath, "r").readlines() labs = parse_mlf(mlf, args.intype) #Used if we make questions fitted to a dataset