31 int main(
int argc,
char *argv[]) {
33 using namespace kaldi;
35 using fst::SymbolTable;
40 "Generate alignments, reading log-likelihoods as matrices.\n" 41 " (model is needed only for the integer mappings in its transition-model)\n" 42 "Usage: align-compiled-mapped [options] trans-model-in graphs-rspecifier feature-rspecifier alignments-wspecifier\n" 44 " nnet-align-compiled trans.mdl ark:graphs.fsts scp:train.scp ark:nnet.ali\n" 46 " compile-train-graphs tree trans.mdl lex.fst ark:train.tra b, ark:- | \\\n" 47 " nnet-align-compiled trans.mdl ark:- scp:loglikes.scp t, ark:nnet.ali\n";
57 po.
Register(
"binary", &binary,
"Write output in binary mode");
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]");
71 std::string model_in_filename = po.
GetArg(1);
72 std::string fst_rspecifier = po.
GetArg(2);
73 std::string feature_rspecifier = po.
GetArg(3);
74 std::string alignment_wspecifier = po.
GetArg(4);
75 std::string scores_wspecifier = po.
GetOptArg(5);
85 int num_done = 0, num_err = 0, num_retry = 0;
86 double tot_like = 0.0;
87 kaldi::int64 frame_count = 0;
89 for (; !loglikes_reader.
Done(); loglikes_reader.
Next()) {
90 std::string utt = loglikes_reader.
Key();
91 if (!fst_reader.
HasKey(utt)) {
97 VectorFst<StdArc> decode_fst(fst_reader.
Value(utt));
103 KALDI_WARN <<
"Empty loglikes matrix utterance: " << utt;
107 if (decode_fst.Start() == fst::kNoStateId) {
108 KALDI_WARN <<
"Empty decoding graph for " << utt;
114 std::vector<int32> disambig_syms;
116 transition_scale, self_loop_scale,
123 acoustic_scale, &decode_fst, &decodable,
124 &alignment_writer, &scores_writer,
125 &num_done, &num_err, &num_retry,
126 &tot_like, &frame_count);
128 KALDI_LOG <<
"Overall log-likelihood per frame is " << (tot_like/frame_count)
129 <<
" over " << frame_count<<
" frames.";
130 KALDI_LOG <<
"Retried " << num_retry <<
" out of " 131 << (num_done + num_err) <<
" utterances.";
132 KALDI_LOG <<
"Done " << num_done <<
", errors on " << num_err;
133 return (num_done != 0 ? 0 : 1);
134 }
catch(
const std::exception &e) {
135 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void Register(OptionsItf *opts)
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
A templated class for writing objects to an archive or script file; see The Table concept...
void Register(const std::string &name, bool *ptr, const std::string &doc)
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
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...
const T & Value(const std::string &key)
int main(int argc, char *argv[])
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
bool HasKey(const std::string &key)
int NumArgs() const
Number of positional parameters (c.f. argc-1).
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...
std::string GetOptArg(int param) const