28 if (phone == 0 || phone_map.empty())
return phone;
29 else if (phone < 0 || phone >= phone_map.size()) {
30 KALDI_ERR <<
"Out-of-range phone " << phone <<
" bad --phone-map option?";
32 return phone_map[phone];
38 const std::vector<int32> &alignment,
40 std::map<EventType, GaussClusterable*> *stats) {
41 std::vector<std::vector<int32> > split_alignment;
42 bool ans =
SplitToPhones(trans_model, alignment, &split_alignment);
44 KALDI_WARN <<
"AccumulateTreeStats: alignment appears to be bad, not using it";
59 bool is_ctx_dep = !std::binary_search(info.
ci_phones.begin(),
65 if (
i +
j >= 0 &&
i +
j < static_cast<int32>(split_alignment.size()))
82 evec.push_back(std::make_pair(static_cast<EventKeyType>(
j), static_cast<EventValueType>(phone)));
90 std::pair<EventKeyType, EventValueType> pr(
kPdfClass, pdf_class);
91 evec_more.push_back(pr);
92 std::sort(evec_more.begin(), evec_more.end());
93 if (stats->count(evec_more) == 0)
97 (*stats)[evec_more]->AddStats(features.
Row(cur_pos), weight);
102 KALDI_ASSERT(cur_pos == static_cast<int32>(alignment.size()));
107 std::vector<int32> *phone_map) {
114 std::vector<std::vector<int32> > vec;
117 KALDI_ERR <<
"Error reading phone map from " <<
119 for (
size_t i = 0;
i < vec.size();
i++) {
120 if (vec[
i].size() != 2 || vec[
i][0]<=0 || vec[
i][1]<=0 ||
121 (vec[
i][0]<
static_cast<int32>(phone_map->size()) &&
122 (*phone_map)[vec[
i][0]] != -1))
123 KALDI_ERR <<
"Error reading phone map from " 125 <<
" (bad line " <<
i <<
")";
126 if (vec[i][0]>=static_cast<int32>(phone_map->size()))
127 phone_map->resize(vec[i][0]+1, -1);
129 (*phone_map)[vec[
i][0]] = vec[
i][1];
131 if (phone_map->empty()) {
132 KALDI_ERR <<
"Read empty phone map from " 139 var_floor(opts.var_floor),
140 context_width(opts.context_width),
141 central_position(opts.central_position) {
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
bool SplitStringToIntegers(const std::string &full, const char *delim, bool omit_empty_strings, std::vector< I > *out)
Split a string (e.g.
std::vector< int32 > phone_map
int32 TransitionIdToPdfClass(int32 trans_id) const
static int32 MapPhone(const std::vector< int32 > &phone_map, int32 phone)
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)...
bool SplitToPhones(const TransitionModel &trans_model, const std::vector< int32 > &alignment, std::vector< std::vector< int32 > > *split_alignment)
SplitToPhones splits up the TransitionIds in "alignment" into their individual phones (one vector per...
static const EventKeyType kPdfClass
void ReadPhoneMap(std::string phone_map_rxfilename, std::vector< int32 > *phone_map)
std::vector< std::pair< EventKeyType, EventValueType > > EventType
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
bool ReadIntegerVectorVectorSimple(const std::string &rxfilename, std::vector< std::vector< int32 > > *list)
std::string ci_phones_str
std::vector< int32 > ci_phones
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
std::string PrintableRxfilename(const std::string &rxfilename)
PrintableRxfilename turns the rxfilename into a more human-readable form for error reporting...
std::string phone_map_rxfilename
GaussClusterable wraps Gaussian statistics in a form accessible to generic clustering algorithms...
bool IsSortedAndUniq(const std::vector< T > &vec)
Returns true if the vector is sorted and contains each element only once.
int32 TransitionIdToPhone(int32 trans_id) const
AccumulateTreeStatsInfo(const AccumulateTreeStatsOptions &opts)