31 std::set<Int> baseline_set;
32 size_t n_in_set = (
Rand() % 3) * 50 + (
Rand() % 4);
33 size_t max = (Int) (
Rand() % 100) + 1;
34 for (
size_t i = 0;
i < n_in_set;
i++) {
35 Int to_add((Int) (
Rand() % max));
36 baseline_set.insert(to_add);
39 std::vector<Int> vector_set;
40 for (
typename std::set<Int>::iterator iter = baseline_set.begin();
41 iter!= baseline_set.end();iter++)
42 vector_set.push_back(*iter);
43 if (vector_set.size() != 0) {
44 for (
size_t i = 0;
i < 10;
i++)
46 vector_set[
Rand()%vector_set.size()]);
54 my_set3.
Init(baseline_set);
57 my_set4.
Init(vector_set);
60 my_set4.
Write(
Output(
"tmpf", binary).Stream(), binary);
66 Input ki(
"tmpf", &binary_in);
72 size_t sz = baseline_set.size(), sz1 = my_set1.
size(), sz2 = my_set2.
size(),
73 sz3 = my_set3.
size(), sz4 = my_set4.
size(), sz5 = my_set5.
size();
74 KALDI_ASSERT(sz == sz1 && sz == sz2 && sz == sz3 && sz == sz4 && sz == sz5);
76 for (
size_t i = 0;
i < 100;
i++) {
78 if (
i%2 == 0 && vector_set.size() != 0)
79 some_int = vector_set[
Rand()%vector_set.size()];
81 some_int =
Rand() % max;
82 bool in_baseline = (baseline_set.count(some_int) != 0);
83 bool in_my_set1 = (my_set1.
count(some_int) != 0);
84 bool in_my_set2 = (my_set2.
count(some_int) != 0);
85 bool in_my_set3 = (my_set3.
count(some_int) != 0);
86 bool in_my_set4 = (my_set4.
count(some_int) != 0);
87 bool in_my_set5 = (my_set5.
count(some_int) != 0);
90 KALDI_ASSERT(in_my_set1&&in_my_set2&&in_my_set3&&in_my_set4&&in_my_set5);
92 KALDI_ASSERT(!in_my_set1&&!in_my_set2&&!in_my_set3&&!in_my_set4&&
98 typename std::set<Int>::iterator baseline_iter = baseline_set.begin();
104 while (baseline_iter != baseline_set.end()) {
135 using namespace kaldi;
136 for (
size_t i = 0;
i < 10;
i++) {
137 TestSetOfNumbers<int>(
Rand()%2);
138 TestSetOfNumbers<unsigned int>(
Rand()%2);
139 TestSetOfNumbers<int16>(
Rand()%2);
140 TestSetOfNumbers<int16>(
Rand()%2);
141 TestSetOfNumbers<char>(
Rand()%2);
142 TestSetOfNumbers<unsigned char>(
Rand()%2);
144 std::cout <<
"Test OK.\n";
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void swap(basic_filebuf< CharT, Traits > &x, basic_filebuf< CharT, Traits > &y)
void Write(std::ostream &os, bool binary) const
void TestSetOfNumbers(bool binary)
int Rand(struct RandomState *state)
void Read(std::istream &is, bool binary)
void Init(const std::vector< I > &input)
#define KALDI_ASSERT(cond)
std::vector< I >::const_iterator iterator