transition-model-test.cc
Go to the documentation of this file.
1 // hmm/transition-model-test.cc
2 
3 // Copyright 2014 Johns Hopkins University
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 "hmm/transition-model.h"
21 #include "hmm/hmm-test-utils.h"
22 
23 namespace kaldi {
24 
25 
27 
28  TransitionModel *trans_model = GenRandTransitionModel(NULL);
29 
30  bool binary = (rand() % 2 == 0);
31 
32  std::ostringstream os;
33  trans_model->Write(os, binary);
34 
35  TransitionModel trans_model2;
36  std::istringstream is2(os.str());
37  trans_model2.Read(is2, binary);
38 
39  {
40  std::ostringstream os1, os2;
41  trans_model->Write(os1, false);
42  trans_model2.Write(os2, false);
43  KALDI_ASSERT(os1.str() == os2.str());
44  KALDI_ASSERT(trans_model->Compatible(trans_model2));
45  }
46  delete trans_model;
47 }
48 
49 }
50 
51 int main() {
52  for (int i = 0; i < 2; i++)
54  KALDI_LOG << "Test OK.\n";
55 }
56 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void Read(std::istream &is, bool binary)
bool Compatible(const TransitionModel &other) const
returns true if all the integer class members are identical (but does not compare the transition prob...
int main()
void Write(std::ostream &os, bool binary) const
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
TransitionModel * GenRandTransitionModel(ContextDependency **ctx_dep_out)
void TestTransitionModel()
#define KALDI_LOG
Definition: kaldi-error.h:153