32 #ifndef KALDI_NO_PORTAUDIO    34     using namespace kaldi;
    41     const int32 kDeltaOrder = 2;
    43     const int32 kTimeout = 500; 
    45     const int32 kSampleFreq = 16000;
    47     const int32 kPaRingSize = 32768;
    49     const int32 kPaReportInt = 4;
    52         "Decode speech, using microphone input(PortAudio)\n\n"    53         "Utterance segmentation is done on-the-fly.\n"    54         "Feature splicing/LDA transform is used, if the optional(last) argument "    56         "Otherwise delta/delta-delta(2-nd order) features are produced.\n\n"    57         "Usage: online-gmm-decode-faster [options] <model-in>"    58         "<fst-in> <word-symbol-table> <silence-phones> [<lda-matrix-in>]\n\n"    59         "Example: online-gmm-decode-faster --rt-min=0.3 --rt-max=0.5 "    60         "--max-active=4000 --beam=12.0 --acoustic-scale=0.0769 "    61         "model HCLG.fst words.txt '1:2:3:4:5' lda-matrix";
    64     int32 cmn_window = 600, min_cmn_window = 100;
    65     int32 right_context = 4, left_context = 4;
    74     po.Register(
"left-context", &left_context, 
"Number of frames of left context");
    75     po.Register(
"right-context", &right_context, 
"Number of frames of right context");
    76     po.Register(
"acoustic-scale", &acoustic_scale,
    77                 "Scaling factor for acoustic likelihoods");
    78     po.Register(
"cmn-window", &cmn_window,
    79         "Number of feat. vectors used in the running average CMN calculation");
    80     po.Register(
"min-cmn-window", &min_cmn_window,
    81                 "Minumum CMN window used at start of decoding (adds "    82                 "latency only at start)");
    85     if (po.NumArgs() != 4 && po.NumArgs() != 5) {
    90     std::string model_rxfilename = po.GetArg(1),
    91         fst_rxfilename = po.GetArg(2),
    92         word_syms_filename = po.GetArg(3),
    93         silence_phones_str = po.GetArg(4),
    94         lda_mat_rspecifier = po.GetOptArg(5);
    97     if (lda_mat_rspecifier != 
"") {
    99       Input ki(lda_mat_rspecifier, &binary_in);
   100       lda_transform.
Read(ki.Stream(), binary_in);
   103     std::vector<int32> silence_phones;
   105         KALDI_ERR << 
"Invalid silence-phones string " << silence_phones_str;
   106     if (silence_phones.empty())
   113         Input ki(model_rxfilename, &binary);
   114         trans_model.
Read(ki.Stream(), binary);
   115         am_gmm.
Read(ki.Stream(), binary);
   118     fst::SymbolTable *word_syms = NULL;
   119     if (!(word_syms = fst::SymbolTable::ReadText(word_syms_filename)))
   120         KALDI_ERR << 
"Could not read symbol table from file "   121                     << word_syms_filename;
   133     int32 window_size = right_context + left_context + 1;
   136                                 silence_phones, trans_model);
   137     VectorFst<LatticeArc> out_fst;
   138     OnlinePaSource au_src(kTimeout, kSampleFreq, kPaRingSize, kPaReportInt);
   139     Mfcc mfcc(mfcc_opts);
   140     FeInput fe_input(&au_src, &mfcc,
   141                      frame_length * (kSampleFreq / 1000),
   142                      frame_shift * (kSampleFreq / 1000));
   145     if (lda_mat_rspecifier != 
"") {
   147                                &cmn_input, lda_transform,
   148                                left_context, right_context);
   151       opts.
order = kDeltaOrder;
   161     bool partial_res = 
false;
   162     decoder.InitDecoding();
   165       if (dstate & (decoder.kEndFeats | decoder.kEndUtt)) {
   166         std::vector<int32> word_ids;
   167         decoder.FinishTraceBack(&out_fst);
   169                                      static_cast<vector<int32> *
>(0),
   171                                      static_cast<LatticeArc::Weight*>(0));
   174         if (dstate == decoder.kEndFeats) {
   175           if (au_src.TimedOut())
   177           KALDI_LOG << 
"No more features available from PortAudio!";
   181         std::vector<int32> word_ids;
   182         if (decoder.PartialTraceback(&out_fst)) {
   184                                        static_cast<vector<int32> *
>(0),
   186                                        static_cast<LatticeArc::Weight*>(0));
   189             partial_res = (word_ids.size() > 0);
   194     delete feat_transform;
   198   } 
catch(
const std::exception& e) {
   199     std::cerr << e.what();
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
void Register(OptionsItf *opts, bool full)
 
MfccOptions contains basic options for computing MFCC features. 
 
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
 
bool SplitStringToIntegers(const std::string &full, const char *delim, bool omit_empty_strings, std::vector< I > *out)
Split a string (e.g. 
 
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. 
 
void PrintPartialResult(const std::vector< int32 > &words, const fst::SymbolTable *word_syms, bool line_break)
 
void Read(std::istream &in, bool binary, bool add=false)
read from stream. 
 
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
 
FrameExtractionOptions frame_opts
 
void Read(std::istream &is, bool binary)
 
fst::Fst< fst::StdArc > * ReadDecodeGraph(const std::string &filename)
 
void Register(OptionsItf *opts)
 
void Register(OptionsItf *opts)
 
This templated class is intended for offline feature extraction, i.e. 
 
void Read(std::istream &in_stream, bool binary)