tree-accu.h
Go to the documentation of this file.
1 // hmm/tree-accu.h
2 
3 // Copyright 2009-2011 Microsoft Corporation
4 // 2013-2015 Johns Hopkins University (author: Daniel Povey)
5 
6 // See ../../COPYING for clarification regarding multiple authors
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 
12 // http://www.apache.org/licenses/LICENSE-2.0
13 
14 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 // MERCHANTABLITY OR NON-INFRINGEMENT.
18 // See the Apache 2 License for the specific language governing permissions and
19 // limitations under the License.
20 #ifndef KALDI_HMM_TREE_ACCU_H_
21 #define KALDI_HMM_TREE_ACCU_H_
22 
23 #include <cctype> // For isspace.
24 #include <limits>
25 #include "base/kaldi-common.h"
26 #include "hmm/transition-model.h"
28 #include "tree/build-tree-questions.h" // needed for this typedef:
29 // typedef std::vector<std::pair<EventVector, Clusterable*> > BuildTreeStatsType;
30 
31 namespace kaldi {
32 
35 
38  std::string ci_phones_str;
39  std::string phone_map_rxfilename;
43  AccumulateTreeStatsOptions(): var_floor(0.01), context_width(3),
44  central_position(1) { }
45 
46 
47  void Register(OptionsItf *opts) {
48  opts->Register("var-floor", &var_floor, "Variance floor for tree "
49  "clustering.");
50  opts->Register("ci-phones", &ci_phones_str, "Colon-separated list of "
51  "integer indices of context-independent phones (after "
52  "mapping, if --phone-map option is used).");
53  opts->Register("context-width", &context_width, "Context window size.");
54  opts->Register("central-position", &central_position, "Central "
55  "context-window position (zero-based)");
56  opts->Register("phone-map", &phone_map_rxfilename,
57  "File name containing old->new phone mapping (each line is: "
58  "old-integer-id new-integer-id)");
59  }
60 };
61 
62 // This class is a binary representation of AccumulateTreeStatsOptions.
65  std::vector<int32> ci_phones; // sorted, uniq vector of context-independent
66  // phones.
67  std::vector<int32> phone_map; // if nonempty, maps old phones to new phones.
71 };
72 
76 
77 void AccumulateTreeStats(const TransitionModel &trans_model,
78  const AccumulateTreeStatsInfo &info,
79  const std::vector<int32> &alignment,
80  const Matrix<BaseFloat> &features,
81  std::map<EventType, GaussClusterable*> *stats);
82 
83 
84 
85 /*** Read a mapping from one phone set to another. The phone map file has lines
86  of the form <old-phone> <new-phone>, where both entries are integers, usually
87  nonzero (but this is not enforced). This program will crash if the input is
88  invalid, e.g. there are multiple inconsistent entries for the same old phone.
89  The output vector "phone_map" will be indexed by old-phone and will contain
90  the corresponding new-phone, or -1 for any entry that was not defined. */
91 
92 void ReadPhoneMap(std::string phone_map_rxfilename,
93  std::vector<int32> *phone_map);
94 
95 
96 
98 
99 } // end namespace kaldi.
100 
101 #endif
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void Register(OptionsItf *opts)
Definition: tree-accu.h:47
std::vector< int32 > phone_map
Definition: tree-accu.h:67
kaldi::int32 int32
void AccumulateTreeStats(const TransitionModel &trans_model, const AccumulateTreeStatsInfo &info, const std::vector< int32 > &alignment, const Matrix< BaseFloat > &features, std::map< EventType, GaussClusterable *> *stats)
Accumulates the stats needed for training context-dependency trees (in the "normal" way)...
Definition: tree-accu.cc:36
virtual void Register(const std::string &name, bool *ptr, const std::string &doc)=0
void ReadPhoneMap(std::string phone_map_rxfilename, std::vector< int32 > *phone_map)
Definition: tree-accu.cc:106
std::vector< int32 > ci_phones
Definition: tree-accu.h:65