tree-info.cc
Go to the documentation of this file.
1 // bin/tree-info.cc
2 
3 // Copyright 2013 Johns Hopkins University (author: Daniel Povey)
4 
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 
20 
21 #include "base/kaldi-common.h"
22 #include "util/common-utils.h"
23 #include "hmm/hmm-topology.h"
24 #include "tree/context-dep.h"
25 
26 int main(int argc, char *argv[]) {
27  using namespace kaldi;
28  try {
29  using namespace kaldi;
30  typedef kaldi::int32 int32;
31 
32  const char *usage =
33  "Print information about decision tree (mainly the number of pdfs), to stdout\n"
34  "Usage: tree-info <tree-in>\n";
35 
36  ParseOptions po(usage);
37 
38  po.Read(argc, argv);
39 
40  if (po.NumArgs() != 1) {
41  po.PrintUsage();
42  exit(1);
43  }
44 
45  std::string tree_in_filename = po.GetArg(1);
46 
47  ContextDependency ctx_dep;
48  ReadKaldiObject(tree_in_filename, &ctx_dep);
49 
50  std::cout << "num-pdfs " << ctx_dep.NumPdfs() << std::endl;
51  std::cout << "context-width " << ctx_dep.ContextWidth() << std::endl;
52  std::cout << "central-position " << ctx_dep.CentralPosition() << std::endl;
53 
54  } catch(const std::exception &e) {
55  std::cerr << e.what();
56  return -1;
57  }
58 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
virtual int32 ContextWidth() const
ContextWidth() returns the value N (e.g.
Definition: context-dep.h:61
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
kaldi::int32 int32
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
Definition: kaldi-io.cc:832
virtual int32 NumPdfs() const
NumPdfs() returns the number of acoustic pdfs (they are numbered 0.. NumPdfs()-1).
Definition: context-dep.h:71
int main(int argc, char *argv[])
Definition: tree-info.cc:26
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
virtual int32 CentralPosition() const
Central position P of the phone context, in 0-based numbering, e.g.
Definition: context-dep.h:62
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).