34 using namespace kaldi;
36 using fst::SymbolTable;
41 "Align features given [GMM-based] models.\n" 42 "Usage: gmm-align-compiled [options] <model-in> <graphs-rspecifier> " 43 "<feature-rspecifier> <alignments-wspecifier> [scores-wspecifier]\n" 45 " gmm-align-compiled 1.mdl ark:graphs.fsts scp:train.scp ark:1.ali\n" 47 " compile-train-graphs tree 1.mdl lex.fst 'ark:sym2int.pl -f 2- words.txt text|' \\\n" 48 " ark:- | gmm-align-compiled 1.mdl ark:- scp:train.scp t, ark:1.ali\n";
55 std::string per_frame_acwt_wspecifier;
58 po.Register(
"transition-scale", &transition_scale,
59 "Transition-probability scale [relative to acoustics]");
60 po.Register(
"acoustic-scale", &acoustic_scale,
61 "Scaling factor for acoustic likelihoods");
62 po.Register(
"self-loop-scale", &self_loop_scale,
63 "Scale of self-loop versus non-self-loop log probs [relative to acoustics]");
64 po.Register(
"write-per-frame-acoustic-loglikes", &per_frame_acwt_wspecifier,
65 "Wspecifier for table of vectors containing the acoustic log-likelihoods " 66 "per frame for each utterance. E.g. ark:foo/per_frame_logprobs.1.ark");
69 if (po.NumArgs() < 4 || po.NumArgs() > 5) {
74 std::string model_in_filename = po.GetArg(1),
75 fst_rspecifier = po.GetArg(2),
76 feature_rspecifier = po.GetArg(3),
77 alignment_wspecifier = po.GetArg(4),
78 scores_wspecifier = po.GetOptArg(5);
84 Input ki(model_in_filename, &binary);
85 trans_model.
Read(ki.Stream(), binary);
86 am_gmm.
Read(ki.Stream(), binary);
95 int num_done = 0, num_err = 0, num_retry = 0;
96 double tot_like = 0.0;
97 kaldi::int64 frame_count = 0;
99 for (; !fst_reader.Done(); fst_reader.Next()) {
100 std::string utt = fst_reader.Key();
101 if (!feature_reader.HasKey(utt)) {
103 KALDI_WARN <<
"No features for utterance " << utt;
106 VectorFst<StdArc> decode_fst(fst_reader.Value());
107 fst_reader.FreeCurrent();
112 KALDI_WARN <<
"Zero-length utterance: " << utt;
118 std::vector<int32> disambig_syms;
120 transition_scale, self_loop_scale,
129 acoustic_scale, &decode_fst, &gmm_decodable,
130 &alignment_writer, &scores_writer,
131 &num_done, &num_err, &num_retry,
132 &tot_like, &frame_count, &per_frame_acwt_writer);
135 KALDI_LOG <<
"Overall log-likelihood per frame is " << (tot_like/frame_count)
136 <<
" over " << frame_count<<
" frames.";
137 KALDI_LOG <<
"Retried " << num_retry <<
" out of " 138 << (num_done + num_err) <<
" utterances.";
139 KALDI_LOG <<
"Done " << num_done <<
", errors on " << num_err;
140 return (num_done != 0 ? 0 : 1);
141 }
catch(
const std::exception &e) {
142 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void Register(OptionsItf *opts)
A templated class for writing objects to an archive or script file; see The Table concept...
Allows random access to a collection of objects in an archive or script file; see The Table concept...
void AddTransitionProbs(const TransitionModel &trans_model, const std::vector< int32 > &disambig_syms, BaseFloat transition_scale, BaseFloat self_loop_scale, fst::VectorFst< fst::StdArc > *fst)
Adds transition-probs, with the supplied scales (see Scaling of transition and acoustic probabilities...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
void Read(std::istream &is, bool binary)
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void AlignUtteranceWrapper(const AlignConfig &config, const std::string &utt, BaseFloat acoustic_scale, fst::VectorFst< fst::StdArc > *fst, DecodableInterface *decodable, Int32VectorWriter *alignment_writer, BaseFloatWriter *scores_writer, int32 *num_done, int32 *num_error, int32 *num_retried, double *tot_like, int64 *frame_count, BaseFloatVectorWriter *per_frame_acwt_writer)
AlignUtteranceWapper is a wrapper for alignment code used in training, that is called from many diffe...
void Read(std::istream &in_stream, bool binary)