hmm-info.cc
Go to the documentation of this file.
1 // bin/hmm-info.cc
2 
3 // Copyright 2012 Johns Hopkins University (Author: Daniel Povey), Karel Vesely
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 #include "base/kaldi-common.h"
21 #include "util/common-utils.h"
22 #include "hmm/transition-model.h"
23 
24 int main(int argc, char *argv[]) {
25  try {
26  using namespace kaldi;
27  typedef kaldi::int32 int32;
28 
29  const char *usage =
30  "Write to standard output various properties of HMM-based transition model\n"
31  "Usage: hmm-info [options] <model-in>\n"
32  "e.g.:\n"
33  " hmm-info trans.mdl\n";
34 
35  ParseOptions po(usage);
36 
37  po.Read(argc, argv);
38 
39  if (po.NumArgs() != 1) {
40  po.PrintUsage();
41  exit(1);
42  }
43 
44  std::string model_in_filename = po.GetArg(1);
45 
46  TransitionModel trans_model;
47  {
48  bool binary_read;
49  Input ki(model_in_filename, &binary_read);
50  trans_model.Read(ki.Stream(), binary_read);
51  }
52 
53  std::cout << "number of phones " << trans_model.GetPhones().size() << '\n';
54  std::cout << "number of pdfs " << trans_model.NumPdfs() << '\n';
55  std::cout << "number of transition-ids " << trans_model.NumTransitionIds()
56  << '\n';
57  std::cout << "number of transition-states "
58  << trans_model.NumTransitionStates() << '\n';
59  } catch(const std::exception &e) {
60  std::cerr << e.what() << '\n';
61  return -1;
62  }
63 }
64 
65 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
const std::vector< int32 > & GetPhones() const
Returns a sorted, unique list of phones.
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
kaldi::int32 int32
std::istream & Stream()
Definition: kaldi-io.cc:826
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
int32 NumTransitionIds() const
Returns the total number of transition-ids (note, these are one-based).
void Read(std::istream &is, bool binary)
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).
int main(int argc, char *argv[])
Definition: hmm-info.cc:24
int32 NumTransitionStates() const
Returns the total number of transition-states (note, these are one-based).