def _decode_cnn_ctc_parse_args(args, logger): parser = KaldiParser( description=decode_cnn_ctc.__doc__, add_verbose=True, logger=logger, ) # any boolean configuration should be kaldi-like # (e.g. --strict=true) parser.register('type', bool, kaldi_bool_arg_type) parser.add_argument('data_rspecifier', type='kaldi_rspecifier', help='rspecifier to read in audio features to decode') parser.add_argument('output_wspecifier', type='kaldi_wspecifier', help='wspecifier to write decoded sequences to') parser.add_argument( 'label_to_id_map_path', help='Where the file that converts labels to ids is stored.') # we add all three sets of arguments as we allow them in the same # config file - we just ignore what we don't want ModelConfig().add_arguments_to_parser(parser) TrainConfig().add_arguments_to_parser(parser) DecodeConfig().add_arguments_to_parser(parser) options = parser.parse_args(args) return options
def _compute_error_rate_parse_args(args, logger): parser = KaldiParser( description=compute_error_rate.__doc__, add_verbose=True, logger=logger, ) parser.add_argument( 'ref_rspecifier', type='kaldi_rspecifier', help='Rspecifier pointing to reference (gold standard) transcriptions') parser.add_argument( 'hyp_rspecifier', type='kaldi_wspecifier', help='Rspecifier pointing to hypothesis transcriptions') parser.add_argument( 'out_path', nargs='?', default=None, help='Path to print results to. Default is stdout.') parser.add_argument( '--print-tables', type='kaldi_bool', default=False, help='If set, will print breakdown of insertions, deletions, and subs ' 'to out_path') parser.add_argument( '--strict', type='kaldi_bool', default=False, help='If set, missing utterances will cause an error') parser.add_argument( '--insertion-cost', type=int, default=1, help='Cost (in terms of edit distance) to perform an insertion') parser.add_argument( '--deletion-cost', type=int, default=1, help='Cost (in terms of edit distance) to perform a deletion') parser.add_argument( '--substitution-cost', type=int, default=1, help='Cost (in terms of edit distance) to perform a substitution') parser.add_argument( '--include-inserts-in-cost', type='kaldi_bool', default=True, help='Whether to include insertions in error rate calculations') parser.add_argument( '--report-accuracy', type='kaldi_bool', default=False, help='Whether to report accuracy (1 - error_rate) instead of ' 'the error rate' ) options = parser.parse_args(args) return options
def _normalize_feat_lens_parse_args(args, logger): parser = KaldiParser( description=normalize_feat_lens.__doc__, add_verbose=True, logger=logger, ) parser.add_argument( 'feats_in_rspecifier', type='kaldi_rspecifier', help='The features to be normalized', ) parser.add_argument( 'len_in_rspecifier', type='kaldi_rspecifier', help='The reference lengths (int32 table)', ) parser.add_argument( 'feats_out_wspecifier', type='kaldi_wspecifier', help='The output features', ) parser.add_argument( '--type', type='kaldi_dtype', default='bm', help='The kaldi type of the input/output features', ) parser.add_argument('--tolerance', type=int, default=float('inf'), help='''\ How many frames deviation from reference to tolerate before error. The default is to be infinitely tolerant (a feat I'm sure we all desire) ''') parser.add_argument('--strict', type='kaldi_bool', default=False, help='''\ Whether missing keys in len_in and lengths beyond the threshold cause an error (true) or are skipped with a warning (false) ''') parser.add_argument('--pad-mode', default='edge', choices=('zero', 'constant', 'edge', 'symmetric', 'mean'), help='''\ If frames are being padded to the features, specify how they should be padded. zero=zero pad, edge=pad with rightmost frame, symmetric=pad with reverse of frame edges, mean=pad with mean feature values ''') parser.add_argument('--side', default='right', choices=('left', 'right', 'center'), help='''\ If an utterance needs to be padded or truncated, specify what side of the utterance to do this on. left=beginning, right=end, center=distribute evenly on either side ''') return parser.parse_args(args)