Go to the source code of this file.
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 60 of file draw-tree.cc.
References ParseOptions::GetArg(), KALDI_ERR, MakeEvent(), ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), ParseOptions::Register(), TreeRenderer::Render(), and Input::Stream().
61 using namespace kaldi;
64 bool use_tooltips =
false;
65 bool gen_html =
false;
68 "Outputs a decision tree description in GraphViz format\n" 69 "Usage: draw-tree [options] <phone-symbols> <tree>\n" 70 "e.g.: draw-tree phones.txt tree | dot -Gsize=8,10.5 -Tps | ps2pdf - tree.pdf\n";
73 po.Register(
"query", &qry,
74 "a query to trace through the tree" 75 "(format: pdf-class/ctx-phone1/.../ctx-phoneN)");
76 po.Register(
"use-tooltips", &use_tooltips,
"use tooltips instead of labels");
77 po.Register(
"gen-html", &gen_html,
"generates HTML boilerplate(useful with SVG)");
80 std::cout <<
"<html>\n<head><title>Decision Tree</tree></head>\n" 81 <<
"<body><object data=\"tree.svg\" type=\"image/svg+xml\"/>" 82 <<
"</body>\n</html>\n";
85 if (po.NumArgs() != 2) {
89 std::string phnfile = po.GetArg(1);
90 std::string treefile = po.GetArg(2);
92 fst::SymbolTable *phones_symtab = NULL;
94 std::ifstream is(phnfile.c_str());
95 phones_symtab = ::fst::SymbolTable::ReadText(is, phnfile);
97 KALDI_ERR <<
"Could not read phones symbol table file "<< phnfile;
107 Input ki(treefile, &binary);
108 renderer =
new TreeRenderer(ki.Stream(), binary, std::cout,
109 *phones_symtab, use_tooltips);
115 }
catch (
const std::exception &e) {
116 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
std::vector< std::pair< EventKeyType, EventValueType > > EventType
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
void MakeEvent(std::string &qry, fst::SymbolTable *phone_syms, kaldi::EventType **query)
void Render(const EventType *query)
◆ MakeEvent()
void MakeEvent |
( |
std::string & |
qry, |
|
|
fst::SymbolTable * |
phone_syms, |
|
|
kaldi::EventType ** |
query |
|
) |
| |
Definition at line 23 of file draw-tree.cc.
References KALDI_ERR, and kaldi::kPdfClass.
Referenced by main().
26 using namespace kaldi;
29 size_t found, old_found = 0;
31 while ((found = qry.find(
'/', old_found)) != std::string::npos) {
32 std::string valstr = qry.substr(old_found, found - old_found);
37 KALDI_ERR <<
"Bad query: invalid pdf-class (" << valstr <<
')';
41 value =
static_cast<EventValueType>(phone_syms->Find(valstr.c_str()));
43 KALDI_ERR <<
"Bad query: invalid symbol (" << valstr <<
')';
46 query_event->push_back(std::make_pair(key++, value));
47 old_found = found + 1;
49 std::string valstr = qry.substr(old_found);
53 KALDI_ERR <<
"Bad query: invalid symbol (" << valstr <<
')';
55 query_event->push_back(std::make_pair(key, value));
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
static const EventKeyType kPdfClass
std::vector< std::pair< EventKeyType, EventValueType > > EventType
int32 EventKeyType
Things of type EventKeyType can take any value.
int32 EventValueType
Given current code, things of type EventValueType should generally be nonnegative and in a reasonably...