OnlineIvectorExtractorAdaptationState Struct Reference

This class stores the adaptation state from the online iVector extractor, which can help you to initialize the adaptation state for the next utterance of the same speaker in a more informed way. More...

#include <online-ivector-feature.h>

Collaboration diagram for OnlineIvectorExtractorAdaptationState:

Public Member Functions

 OnlineIvectorExtractorAdaptationState (const OnlineIvectorExtractionInfo &info)
 This constructor initializes adaptation-state with no prior speaker history. More...
 
 OnlineIvectorExtractorAdaptationState (const OnlineIvectorExtractorAdaptationState &other)
 Copy constructor. More...
 
void LimitFrames (BaseFloat max_remembered_frames, BaseFloat posterior_scale)
 Scales down the stats if needed to ensure the number of frames in the speaker-specific CMVN stats does not exceed max_remembered_frames and the data-count in the iVector stats does not exceed max_remembered_frames * posterior_scale. More...
 
void Write (std::ostream &os, bool binary) const
 
void Read (std::istream &is, bool binary)
 

Public Attributes

OnlineCmvnState cmvn_state
 
OnlineIvectorEstimationStats ivector_stats
 Stats for online iVector estimation. More...
 

Detailed Description

This class stores the adaptation state from the online iVector extractor, which can help you to initialize the adaptation state for the next utterance of the same speaker in a more informed way.

Definition at line 211 of file online-ivector-feature.h.

Constructor & Destructor Documentation

◆ OnlineIvectorExtractorAdaptationState() [1/2]

This constructor initializes adaptation-state with no prior speaker history.

Definition at line 223 of file online-ivector-feature.h.

References OnlineIvectorExtractionConfig::max_remembered_frames, and OnlineIvectorExtractionConfig::posterior_scale.

223  :
224  cmvn_state(info.global_cmvn_stats),
225  ivector_stats(info.extractor.IvectorDim(),
226  info.extractor.PriorOffset(),
227  info.max_count) { }
OnlineIvectorEstimationStats ivector_stats
Stats for online iVector estimation.

◆ OnlineIvectorExtractorAdaptationState() [2/2]

Copy constructor.

Definition at line 104 of file online-ivector-feature.cc.

105  :
106  cmvn_state(other.cmvn_state), ivector_stats(other.ivector_stats) { }
OnlineIvectorEstimationStats ivector_stats
Stats for online iVector estimation.

Member Function Documentation

◆ LimitFrames()

void LimitFrames ( BaseFloat  max_remembered_frames,
BaseFloat  posterior_scale 
)

Scales down the stats if needed to ensure the number of frames in the speaker-specific CMVN stats does not exceed max_remembered_frames and the data-count in the iVector stats does not exceed max_remembered_frames * posterior_scale.

[the posterior_scale factor is necessary because those stats have already been scaled by that factor.]

Definition at line 109 of file online-ivector-feature.cc.

References OnlineIvectorExtractorAdaptationState::cmvn_state, count, OnlineIvectorEstimationStats::Count(), OnlineCmvnState::frozen_state, OnlineIvectorExtractorAdaptationState::ivector_stats, KALDI_ASSERT, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), MatrixBase< Real >::Scale(), OnlineIvectorEstimationStats::Scale(), and OnlineCmvnState::speaker_cmvn_stats.

Referenced by OnlineIvectorFeature::GetAdaptationState().

110  {
111  KALDI_ASSERT(max_remembered_frames >= 0);
114  int32 feat_dim = cmvn_state.speaker_cmvn_stats.NumCols() - 1;
116  if (count > max_remembered_frames)
117  cmvn_state.speaker_cmvn_stats.Scale(max_remembered_frames / count);
118  }
119  // the stats for the iVector have been scaled by info_.posterior_scale,
120  // so we need to take this in account when setting the target count.
121  BaseFloat max_remembered_frames_scaled =
122  max_remembered_frames * posterior_scale;
123  if (ivector_stats.Count() > max_remembered_frames_scaled) {
124  ivector_stats.Scale(max_remembered_frames_scaled /
125  ivector_stats.Count());
126  }
127 }
Matrix< double > speaker_cmvn_stats
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
Definition: kaldi-matrix.h:67
Matrix< double > frozen_state
kaldi::int32 int32
const size_t count
float BaseFloat
Definition: kaldi-types.h:29
OnlineIvectorEstimationStats ivector_stats
Stats for online iVector estimation.
void Scale(Real alpha)
Multiply each element with a scalar value.
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition: kaldi-matrix.h:64
void Scale(double scale)
Scales the number of frames of stats by 0 <= scale <= 1, to make it as if we had fewer frames of adap...

◆ Read()

void Read ( std::istream &  is,
bool  binary 
)

Definition at line 138 of file online-ivector-feature.cc.

References OnlineIvectorExtractorAdaptationState::cmvn_state, kaldi::ExpectToken(), OnlineIvectorExtractorAdaptationState::ivector_stats, OnlineCmvnState::Read(), and OnlineIvectorEstimationStats::Read().

138  {
139  ExpectToken(is, binary, "<OnlineIvectorExtractorAdaptationState>"); // magic string.
140  ExpectToken(is, binary, "<CmvnState>");
141  cmvn_state.Read(is, binary);
142  ExpectToken(is, binary, "<IvectorStats>");
143  ivector_stats.Read(is, binary);
144  ExpectToken(is, binary, "</OnlineIvectorExtractorAdaptationState>");
145 }
void Read(std::istream &is, bool binary)
void Read(std::istream &is, bool binary)
OnlineIvectorEstimationStats ivector_stats
Stats for online iVector estimation.
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
Definition: io-funcs.cc:191

◆ Write()

void Write ( std::ostream &  os,
bool  binary 
) const

Definition at line 129 of file online-ivector-feature.cc.

References OnlineIvectorExtractorAdaptationState::cmvn_state, OnlineIvectorExtractorAdaptationState::ivector_stats, OnlineCmvnState::Write(), OnlineIvectorEstimationStats::Write(), and kaldi::WriteToken().

129  {
130  WriteToken(os, binary, "<OnlineIvectorExtractorAdaptationState>"); // magic string.
131  WriteToken(os, binary, "<CmvnState>");
132  cmvn_state.Write(os, binary);
133  WriteToken(os, binary, "<IvectorStats>");
134  ivector_stats.Write(os, binary);
135  WriteToken(os, binary, "</OnlineIvectorExtractorAdaptationState>");
136 }
void Write(std::ostream &os, bool binary) const
OnlineIvectorEstimationStats ivector_stats
Stats for online iVector estimation.
void Write(std::ostream &os, bool binary) const
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
Definition: io-funcs.cc:134

Member Data Documentation

◆ cmvn_state

◆ ivector_stats


The documentation for this struct was generated from the following files: