27 int32 n = 10 + rand () % 50, gselect = 1 + rand() % 5;
34 std::vector<std::pair<int32, BaseFloat> > post_entry;
41 loglikes.
Max(&max_elem);
45 KALDI_ASSERT(post_entry.back().second <= post_entry.front().second);
48 for (
size_t i = 0;
i < post_entry.size();
i++)
49 sum += post_entry[
i].second;
55 post_size = post_size * post_size;
57 for (
int32 i = 0;
i < post.size();
i++) {
60 post[
i].push_back(std::pair<int32,BaseFloat>(
63 bool binary = (
RandInt(0, 1) == 0);
64 std::ostringstream os;
69 std::istringstream is(os.str());
75 for (
int32 i = 0;
i < post.size();
i++) {
77 for (
int32 j = 0;
j < post[
i].size();
j++) {
79 fabs(post[
i][
j].second - post2[
i][
j].second) < 0.01);
88 for (
int i = 0;
i < 10;
i++) {
92 std::cout <<
"Test OK.\n";
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
float RandUniform(struct RandomState *state=NULL)
Returns a random number strictly between 0 and 1.
BaseFloat VectorToPosteriorEntry(const VectorBase< BaseFloat > &log_likes, int32 num_gselect, BaseFloat min_post, std::vector< std::pair< int32, BaseFloat > > *post_entry)
Given a vector of log-likelihoods (typically of Gaussians in a GMM but could be of pdf-ids)...
std::vector< std::vector< std::pair< int32, BaseFloat > > > Posterior
Posterior is a typedef for storing acoustic-state (actually, transition-id) posteriors over an uttera...
Real Max() const
Returns the maximum value of any element, or -infinity for the empty vector.
void Scale(Real alpha)
Multiplies all elements by this constant.
void SetRandn()
Set vector to random normally-distributed noise.
A class representing a vector.
#define KALDI_ASSERT(cond)
void TestVectorToPosteriorEntry()
void WritePosterior(std::ostream &os, bool binary, const Posterior &post)
stand-alone function for writing a Posterior.
void ReadPosterior(std::istream &is, bool binary, Posterior *post)
stand-alone function for reading a Posterior.
int32 RandInt(int32 min_val, int32 max_val, struct RandomState *state)