23 #ifndef KALDI_HMM_POSTERIOR_H_ 24 #define KALDI_HMM_POSTERIOR_H_ 42 typedef std::vector<std::vector<std::pair<int32, BaseFloat> > >
Posterior;
51 typedef std::vector<std::vector<std::pair<int32, Vector<BaseFloat> > > >
GaussPost;
64 static bool Write(std::ostream &os,
bool binary,
const T &t);
69 bool Read(std::istream &is);
82 KALDI_ERR <<
"ExtractRange is not defined for this type of holder.";
92 void WritePosterior(std::ostream &os,
bool binary,
const Posterior &post);
95 void ReadPosterior(std::istream &os,
bool binary, Posterior *post);
108 static bool Write(std::ostream &os,
bool binary,
const T &t);
113 bool Read(std::istream &is);
126 KALDI_ERR <<
"ExtractRange is not defined for this type of holder.";
157 const std::vector<std::pair<int32, BaseFloat> > &post_elem1,
158 const std::vector<std::pair<int32, BaseFloat> > &post_elem2);
169 const Posterior &post2,
180 bool operator() (
const std::pair<int32, BaseFloat> &a,
181 const std::pair<int32, BaseFloat> &b) {
182 return (a.second > b.second);
199 std::vector<std::pair<int32, BaseFloat> > *post_entry);
215 const Posterior &post_in,
216 Posterior *post_out);
221 const Posterior &post_in,
222 Posterior *post_out);
247 template <
typename Real>
255 template <
typename Real>
void PosteriorToMatrix(const Posterior &post, const int32 post_dim, Matrix< Real > *mat)
This converts a Posterior to a Matrix.
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
static bool IsReadInBinary()
void PosteriorToPdfMatrix(const Posterior &post, const TransitionModel &model, Matrix< Real > *mat)
This converts a Posterior to a Matrix.
SequentialTableReader< PosteriorHolder > SequentialPosteriorReader
static bool Write(std::ostream &os, bool binary, const T &t)
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)...
void swap(basic_filebuf< CharT, Traits > &x, basic_filebuf< CharT, Traits > &y)
A templated class for writing objects to an archive or script file; see The Table concept...
A class for storing matrices.
SequentialTableReader< GaussPostHolder > SequentialGaussPostReader
static bool IsReadInBinary()
RandomAccessTableReader< PosteriorHolder > RandomAccessPosteriorReader
BaseFloat TotalPosterior(const Posterior &post)
Returns the total of all the weights in "post".
void WeightSilencePost(const TransitionModel &trans_model, const ConstIntegerSet< int32 > &silence_set, BaseFloat silence_scale, Posterior *post)
Weight any silence phones in the posterior (i.e.
Allows random access to a collection of objects in an archive or script file; see The Table concept...
bool Read(std::istream &is)
void SortPosteriorByPdfs(const TransitionModel &tmodel, Posterior *post)
Sorts posterior entries so that transition-ids with same pdf-id are next to each other.
void Swap(GaussPostHolder *other)
std::vector< std::vector< std::pair< int32, BaseFloat > > > Posterior
Posterior is a typedef for storing acoustic-state (actually, transition-id) posteriors over an uttera...
bool ExtractRange(const GaussPostHolder &other, const std::string &range)
KALDI_DISALLOW_COPY_AND_ASSIGN(PosteriorHolder)
void WeightSilencePostDistributed(const TransitionModel &trans_model, const ConstIntegerSet< int32 > &silence_set, BaseFloat silence_scale, Posterior *post)
This is similar to WeightSilencePost, except that on each frame it works out the amount by which the ...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
void AlignmentToPosterior(const std::vector< int32 > &ali, Posterior *post)
Convert an alignment to a posterior (with a scale of 1.0 on each entry).
bool PosteriorEntriesAreDisjoint(const std::vector< std::pair< int32, BaseFloat > > &post_elem1, const std::vector< std::pair< int32, BaseFloat > > &post_elem2)
Returns true if the two lists of pairs have no common .first element.
RandomAccessTableReader< GaussPostHolder > RandomAccessGaussPostReader
void ScalePosterior(BaseFloat scale, Posterior *post)
Scales the BaseFloat (weight) element in the posterior entries.
TableWriter< GaussPostHolder > GaussPostWriter
void Swap(PosteriorHolder *other)
void WritePosterior(std::ostream &os, bool binary, const Posterior &post)
stand-alone function for writing a Posterior.
TableWriter< PosteriorHolder > PosteriorWriter
void ConvertPosteriorToPhones(const TransitionModel &tmodel, const Posterior &post_in, Posterior *post_out)
Converts a posterior over transition-ids to be a posterior over phones.
std::vector< std::vector< std::pair< int32, Vector< BaseFloat > > > > GaussPost
GaussPost is a typedef for storing Gaussian-level posteriors for an utterance.
Provides a vector abstraction class.
void ConvertPosteriorToPdfs(const TransitionModel &tmodel, const Posterior &post_in, Posterior *post_out)
Converts a posterior over transition-ids to be a posterior over pdf-ids.
int32 MergePosteriors(const Posterior &post1, const Posterior &post2, bool merge, bool drop_frames, Posterior *post)
Merge two sets of posteriors, which must have the same length.
void ReadPosterior(std::istream &is, bool binary, Posterior *post)
stand-alone function for reading a Posterior.
bool ExtractRange(const PosteriorHolder &other, const std::string &range)