29 std::vector<Index> indexes(
RandInt(0, 10));
31 for (
int32 i = 0;
i < indexes.size();
i++) {
38 indexes[
i].n = indexes[
i-1].n;
39 indexes[
i].t = indexes[
i-1].t +
RandInt(-127, 127);
40 indexes[
i].x = indexes[
i-1].x;
44 std::ostringstream os;
45 bool binary = (
RandInt(0, 1) == 0);
48 std::vector<Index> indexes2;
51 std::istringstream is(os.str());
53 if (indexes != indexes2) {
55 std::cerr <<
" vs. \n";
63 std::vector<Cindex> cindexes(
RandInt(0, 15));
65 for (
int32 i = 0;
i < cindexes.size();
i++) {
67 cindexes[
i].first =
RandInt(-256, 256);
69 cindexes[
i].first = cindexes[
i-1].first;
71 Index &index = cindexes[
i].second;
80 }
else if (
RandInt(0, 1) == 0) {
82 }
else if (
RandInt(0, 1) == 0) {
83 index.
t = std::numeric_limits<int32>::min();
87 }
else if (
RandInt(0, 1) == 0) {
94 index.
t = std::numeric_limits<int32>::min();
100 cindexes[
i].second.n = cindexes[
i-1].second.n;
101 cindexes[
i].second.x = cindexes[
i-1].second.x;
103 cindexes[
i].second.t = cindexes[
i-1].second.t +
RandInt(-127, 127);
104 }
else if (
RandInt(0, 1) == 0) {
105 cindexes[
i].second.t = cindexes[
i-1].second.t + 124;
106 }
else if (
RandInt(0, 1) == 0) {
107 cindexes[
i].second.t = cindexes[
i-1].second.t + -124;
108 }
else if (
RandInt(0, 1) == 0) {
109 cindexes[
i].second.t = std::numeric_limits<int32>::min();
111 cindexes[
i].second.t =
RandInt(-2, 2);
113 }
else if (
RandInt(0, 1) == 0) {
114 cindexes[
i].second.t = cindexes[
i-1].second.t;
115 cindexes[
i].second.x = cindexes[
i-1].second.x;
116 cindexes[
i].second.n = cindexes[
i-1].second.n +
RandInt(-2,2);
117 }
else if (
RandInt(0, 1) == 0) {
118 cindexes[
i].second.t = cindexes[
i-1].second.t +
RandInt(-2, 2);
119 cindexes[
i].second.x = cindexes[
i-1].second.x +
RandInt(-2, 2);
120 cindexes[
i].second.n = cindexes[
i-1].second.n +
RandInt(-2,2);
122 cindexes[
i].second.t = std::numeric_limits<int32>::min();
125 cindexes[
i].second.t =
RandInt(-128, 128);
126 cindexes[
i].second.x =
RandInt(-128, 128);
127 cindexes[
i].second.n =
RandInt(-128, 128);
129 cindexes[
i].second.t = std::numeric_limits<int32>::min();
138 cindexes.resize(4, temp);
139 cindexes[
RandInt(0, 3)].second.t = std::numeric_limits<int32>::min();
142 std::ostringstream os;
143 bool binary = (
RandInt(0, 1) == 0);
145 std::vector<Cindex> cindexes2;
147 cindexes2 = cindexes;
148 std::istringstream is(os.str());
151 std::ostringstream os2;
154 if (cindexes != cindexes2 || os.str() != os2.str()) {
156 std::cerr <<
" vs. \n";
167 using namespace kaldi;
175 KALDI_LOG <<
"Nnet-common tests succeeded.";
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void WriteIndexVector(std::ostream &os, bool binary, const std::vector< Index > &vec)
void ReadCindexVector(std::istream &is, bool binary, std::vector< Cindex > *vec)
struct Index is intended to represent the various indexes by which we number the rows of the matrices...
std::pair< int32, Index > Cindex
void WriteCindexVector(std::ostream &os, bool binary, const std::vector< Cindex > &vec)
void ReadIndexVector(std::istream &is, bool binary, std::vector< Index > *vec)
int32 RandInt(int32 min_val, int32 max_val, struct RandomState *state)