26 int main(
int argc,
char *argv[]) {
27 using namespace kaldi;
31 "Sum statistics for phonetic-context tree building.\n" 32 "Usage: sum-tree-stats [options] tree-accs-out tree-accs-in1 tree-accs-in2 ...\n" 34 " sum-tree-stats treeacc 1.treeacc 2.treeacc 3.treeacc\n";
39 po.
Register(
"binary", &binary,
"Write output in binary mode");
47 std::map<EventType, Clusterable*> tree_stats;
49 std::string tree_stats_wxfilename = po.
GetArg(1);
54 for (int32 arg = 2; arg <= po.
NumArgs(); arg++) {
55 std::string tree_stats_rxfilename = po.
GetArg(arg);
57 Input ki(tree_stats_rxfilename, &binary_in);
61 for (BuildTreeStatsType::iterator iter = stats_array.begin();
62 iter != stats_array.end(); ++iter) {
65 std::map<EventType, Clusterable*>::iterator map_iter = tree_stats.find(e);
66 if (map_iter == tree_stats.end()) {
69 map_iter->second->
Add(*c);
77 for (std::map<EventType, Clusterable*>::const_iterator iter = tree_stats.begin();
78 iter != tree_stats.end();
80 stats.push_back(std::make_pair(iter->first, iter->second));
85 Output ko(tree_stats_wxfilename, binary);
88 KALDI_LOG <<
"Wrote summed accs ( " << stats.size() <<
" individual stats)";
90 return (stats.size() != 0 ? 0 : 1);
91 }
catch(
const std::exception &e) {
92 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
virtual void Add(const Clusterable &other)=0
Add other stats.
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
void Register(const std::string &name, bool *ptr, const std::string &doc)
void DeleteBuildTreeStats(BuildTreeStatsType *stats)
This frees the Clusterable* pointers in "stats", where non-NULL, and sets them to NULL...
void ReadBuildTreeStats(std::istream &is, bool binary, const Clusterable &example, BuildTreeStatsType *stats)
Reads BuildTreeStats object.
std::vector< std::pair< EventKeyType, EventValueType > > EventType
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
int main(int argc, char *argv[])
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
int NumArgs() const
Number of positional parameters (c.f. argc-1).
std::vector< std::pair< EventType, Clusterable * > > BuildTreeStatsType
GaussClusterable wraps Gaussian statistics in a form accessible to generic clustering algorithms...
void WriteBuildTreeStats(std::ostream &os, bool binary, const BuildTreeStatsType &stats)
Writes BuildTreeStats object. This works even if pointers are NULL.