28 bool binary = (
Rand()%2 == 0);
30 std::string input_str =
"<Topology>\n" 32 "<ForPhones> 1 2 3 4 5 6 7 8 9 </ForPhones>\n" 33 "<State> 0 <PdfClass> 0\n" 34 "<Transition> 0 0.5\n" 35 "<Transition> 1 0.5\n" 37 "<State> 1 <PdfClass> 1 \n" 38 "<Transition> 1 0.5\n" 39 "<Transition> 2 0.5\n" 41 " <State> 2 <PdfClass> 2\n" 42 " <Transition> 2 0.5\n" 43 " <Transition> 3 0.5\n" 45 " <State> 3 </State>\n" 48 " <ForPhones> 10 11 13 </ForPhones>\n" 49 " <State> 0 <PdfClass> 0\n" 50 " <Transition> 0 0.5\n" 51 " <Transition> 1 0.5\n" 53 " <State> 1 <PdfClass> 1 \n" 54 " <Transition> 1 0.5\n" 55 " <Transition> 2 0.5\n" 61 std::string chain_input_str =
"<Topology>\n" 63 "<ForPhones> 1 2 3 4 5 6 7 8 9 </ForPhones>\n" 64 " <State> 0 <ForwardPdfClass> 0 <SelfLoopPdfClass> 1\n" 65 " <Transition> 0 0.5\n" 66 " <Transition> 1 0.5\n" 68 " <State> 1 </State>\n" 77 std::istringstream iss(input_str);
78 topo.
Read(iss,
false);
83 std::ostringstream oss;
84 topo.
Write(oss, binary);
88 std::istringstream iss2(oss.str());
89 topo2.
Read(iss2, binary);
92 std::ostringstream oss1, oss2;
93 topo.
Write(oss1,
false);
94 topo2.
Write(oss2,
false);
100 std::istringstream chain_iss(chain_input_str);
101 chain_topo.
Read(chain_iss,
false);
106 std::vector<int32> phones;
118 for (
int i = 0;
i < 10;
i++) {
121 std::cout <<
"Test OK.\n";
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
HmmTopology GetDefaultTopology(const std::vector< int32 > &phones_in)
This function returns a HmmTopology object giving a normal 3-state topology, covering all phones in t...
A class for storing topology information for phones.
void Read(std::istream &is, bool binary)
HmmTopology GenRandTopology(const std::vector< int32 > &phones_in, const std::vector< int32 > &num_pdf_classes)
This method of generating an arbitrary HmmTopology object allows you to specify the number of pdf-cla...
void Write(std::ostream &os, bool binary) const
int Rand(struct RandomState *state)
#define KALDI_ASSERT(cond)
int32 MinLength(int32 phone) const
int32 RandInt(int32 min_val, int32 max_val, struct RandomState *state)