58 using namespace kaldi;
60 using namespace kaldi;
65 "Usage: compile-questions [options] <topo> <questions-text-file> <questions-out>\n" 67 " compile-questions questions.txt questions.qst\n";
70 int32 num_iters_refine = 0;
74 po.Register(
"binary", &binary,
75 "Write output in binary mode");
76 po.Register(
"context-width", &N,
77 "Context window size [must match acc-tree-stats].");
78 po.Register(
"central-position", &P,
79 "Central position in phone context window [must match acc-tree-stats]");
80 po.Register(
"num-iters-refine", &num_iters_refine,
81 "Number of iters of refining questions at each node. >0 --> questions " 86 if (po.NumArgs() != 3) {
92 topo_filename = po.GetArg(1),
93 questions_rxfilename = po.GetArg(2),
94 questions_out_filename = po.GetArg(3);
100 std::vector<std::vector<int32> > questions;
102 KALDI_ERR <<
"Could not read questions from " 104 for (
size_t i = 0;
i < questions.size();
i++) {
105 std::sort(questions[
i].begin(), questions[
i].end());
107 KALDI_ERR <<
"Questions contain duplicate phones";
109 size_t nq =
static_cast<int32
>(questions.size());
111 if (questions.size() != nq)
113 <<
" duplicate questions present in " << questions_rxfilename;
119 int32 max_num_pdfclasses =
ProcessTopo(topo, questions);
126 for (int32
n = 0;
n < N;
n++) {
127 KALDI_LOG <<
"Setting questions for phonetic-context position "<<
n;
128 phone_opts.initial_questions = questions;
133 std::vector<std::vector<int32> > pdfclass_questions(max_num_pdfclasses-1);
134 for (int32
i = 0;
i < max_num_pdfclasses - 1;
i++)
135 for (int32
j = 0;
j <=
i;
j++)
136 pdfclass_questions[
i].push_back(
j);
138 pdfclass_opts.initial_questions = pdfclass_questions;
139 KALDI_LOG <<
"Setting questions for hmm-position [hmm-position ranges from 0 to "<< (max_num_pdfclasses-1) <<
"]";
143 KALDI_LOG <<
"Wrote questions to "<<questions_out_filename;
144 }
catch(
const std::exception &e) {
145 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
This class defines, for each EventKeyType, a set of initial questions that it tries and also a number...
A class for storing topology information for phones.
int32 ProcessTopo(const HmmTopology &topo, const std::vector< std::vector< int32 > > &questions)
void SetQuestionsOf(EventKeyType key, const QuestionsForKey &options_of_key)
void SortAndUniq(std::vector< T > *vec)
Sorts and uniq's (removes duplicates) from a vector.
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
static const EventKeyType kPdfClass
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
bool ReadIntegerVectorVectorSimple(const std::string &rxfilename, std::vector< std::vector< int32 > > *list)
QuestionsForKey is a class used to define the questions for a key, and also options that allow us to ...
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
std::string PrintableRxfilename(const std::string &rxfilename)
PrintableRxfilename turns the rxfilename into a more human-readable form for error reporting...
bool IsSortedAndUniq(const std::vector< T > &vec)
Returns true if the vector is sorted and contains each element only once.