27 bool GetUtteranceId(
const std::string &nbest_id, std::string *utterance_id) {
    28   size_t pos = nbest_id.find_last_of(
'-');
    29   if (pos == std::string::npos || pos == 0) 
return false;
    31     *utterance_id = std::string(nbest_id, 0, pos);
    36 int main(
int argc, 
char *argv[]) {
    38     using namespace kaldi;
    42         "Read in a Table containing N-best entries from a lattices (i.e. individual\n"    43         "lattices with a linear structure, one for each N-best entry, indexed by\n"    44         "utt_id_a-1, utt_id_a-2, etc., and take the union of them for each utterance\n"    45         "id (e.g. utt_id_a), outputting a lattice for each.\n"    46         "Usage:  nbest-to-lattice <nbest-rspecifier> <lattices-wspecifier>\n"    47         " e.g.: nbest-to-lattice ark:1.nbest ark:1.lats\n";
    58     std::string nbest_rspecifier = po.
GetArg(1),
    59         lats_wspecifier = po.
GetArg(2);
    65     int32 n_nbest_done = 0, n_utt_done = 0;
    70     std::string cur_utt_id;
    72     for (; !compact_nbest_reader.
Done(); compact_nbest_reader.
Next()) {
    73       std::string nbest_id = compact_nbest_reader.
Key();
    77         KALDI_ERR << 
"Invalid n-best id " << nbest_id << 
": make sure you "    78             "are giving N-bests to nbest-to-lattice.";
    80       if (utt_id != cur_utt_id) { 
    81         if (cur_utt_id != 
"") {
    82           compact_lattice_writer.
Write(cur_utt_id, cur_union);
    83           cur_union.DeleteStates();
    89       Union(&cur_union, this_nbest);
    94       compact_lattice_writer.
Write(cur_utt_id, cur_union);
    96     KALDI_LOG << 
"Done joining n-best into lattices for "    97               << n_utt_done << 
" utterances, with on average "    98               << (n_nbest_done/
static_cast<BaseFloat>(n_utt_done))
    99               << 
" N-best paths per utterance.";
   100     return (n_utt_done != 0 ? 0 : 1);
   101   } 
catch(
const std::exception &e) {
   102     std::cerr << e.what();
 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
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 Write(const std::string &key, const T &value) const
 
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...
 
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. 
 
fst::VectorFst< CompactLatticeArc > CompactLattice
 
int NumArgs() const
Number of positional parameters (c.f. argc-1). 
 
int main(int argc, char *argv[])
 
bool GetUtteranceId(const std::string &nbest_id, std::string *utterance_id)