Write an equally spaced alignment (for getting training started).
33 using namespace kaldi;
35 using fst::SymbolTable;
39 const char *usage =
"Write an equally spaced alignment (for getting training started)" 40 "Usage: align-equal-compiled <graphs-rspecifier> <features-rspecifier> <alignments-wspecifier>\n" 42 " align-equal-compiled 1.fsts scp:train.scp ark:equal.ali\n";
46 po.Register(
"binary", &binary,
"Write output in binary mode");
49 if (po.NumArgs() != 3) {
55 fst_rspecifier = po.GetArg(1),
56 feature_rspecifier = po.GetArg(2),
57 alignment_wspecifier = po.GetArg(3);
64 int32 done = 0, no_feat = 0, error = 0;
66 for (; !fst_reader.Done(); fst_reader.Next()) {
67 std::string key = fst_reader.Key();
68 if (!feature_reader.HasKey(key)) {
69 KALDI_WARN <<
"No features for utterance " << key;
73 VectorFst<StdArc> decode_fst(fst_reader.Value());
74 fst_reader.FreeCurrent();
79 KALDI_WARN <<
"Zero-length utterance: " << key;
83 if (decode_fst.Start() == fst::kNoStateId) {
84 KALDI_WARN <<
"Empty decoding graph for " << key;
89 VectorFst<StdArc> path;
93 std::vector<int32> aligned_seq,
words;
97 alignment_writer.Write(key, aligned_seq);
100 KALDI_WARN <<
"AlignEqual: did not align utterence " << key;
106 if (done != 0 && no_feat == 0 && error == 0) {
107 KALDI_LOG <<
"Success: done " << done <<
" utterances.";
109 KALDI_WARN <<
"Computed " << done <<
" alignments; " << no_feat
110 <<
" lacked features, " << error
111 <<
" had other errors.";
113 if (done != 0)
return 0;
115 }
catch(
const std::exception &e) {
116 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
A templated class for writing objects to an archive or script file; see The Table concept...
A hashing function object for strings.
bool GetLinearSymbolSequence(const Fst< Arc > &fst, std::vector< I > *isymbols_out, std::vector< I > *osymbols_out, typename Arc::Weight *tot_weight_out)
GetLinearSymbolSequence gets the symbol sequence from a linear FST.
Allows random access to a collection of objects in an archive or script file; see The Table concept...
bool EqualAlign(const Fst< Arc > &ifst, typename Arc::StateId length, int rand_seed, MutableFst< Arc > *ofst, int num_retries)
EqualAlign is similar to RandGen, but it generates a sequence with exactly "length" input symbols...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
fst::StdArc::Weight Weight
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).