This decodable class returns log-likes stored in a matrix; it supports repeatedly writing to the matrix and setting a time-offset representing the frame-index of the first row of the matrix. More...
#include <decodable-matrix.h>
Public Member Functions | |
DecodableMatrixMappedOffset (const TransitionModel &tm) | |
int32 | FirstAvailableFrame () const |
void | AcceptLoglikes (Matrix< BaseFloat > *loglikes, int32 frames_to_discard) |
void | InputIsFinished () |
virtual int32 | NumFramesReady () const |
The call NumFramesReady() will return the number of frames currently available for this decodable object. More... | |
virtual bool | IsLastFrame (int32 frame) const |
Returns true if this is the last frame. More... | |
virtual BaseFloat | LogLikelihood (int32 frame, int32 tid) |
Returns the log likelihood, which will be negated in the decoder. More... | |
virtual int32 | NumIndices () const |
Returns the number of states in the acoustic model (they will be indexed one-based, i.e. More... | |
virtual | ~DecodableMatrixMappedOffset () |
Public Member Functions inherited from DecodableInterface | |
virtual | ~DecodableInterface () |
Private Member Functions | |
KALDI_DISALLOW_COPY_AND_ASSIGN (DecodableMatrixMappedOffset) | |
Private Attributes | |
const TransitionModel & | trans_model_ |
Matrix< BaseFloat > | loglikes_ |
int32 | frame_offset_ |
bool | input_is_finished_ |
BaseFloat * | raw_data_ |
int32 | stride_ |
This decodable class returns log-likes stored in a matrix; it supports repeatedly writing to the matrix and setting a time-offset representing the frame-index of the first row of the matrix.
It's intended for use in multi-threaded decoding; mutex and semaphores are not included. External code will call SetLoglikes() each time more log-likelihods are available. If you try to access a log-likelihood that's no longer available because the frame index is less than the current offset, it is of course an error.
See also DecodableMatrixMapped, which supports the same type of thing but with a different interface where you are expected to re-construct the object each time you want to decode.
Definition at line 152 of file decodable-matrix.h.
|
inline |
Definition at line 154 of file decodable-matrix.h.
|
inlinevirtual |
Definition at line 193 of file decodable-matrix.h.
Definition at line 81 of file decodable-matrix.cc.
References DecodableMatrixMapped::frame_offset_, KALDI_ASSERT, MatrixBase< Real >::NumCols(), TransitionModel::NumPdfs(), MatrixBase< Real >::NumRows(), DecodableMatrixMapped::raw_data_, Matrix< Real >::Resize(), MatrixBase< Real >::RowRange(), DecodableMatrixMapped::stride_, and DecodableMatrixMapped::trans_model_.
Referenced by SingleUtteranceNnet2DecoderThreaded::RunNnetEvaluationInternal().
|
inline |
Definition at line 158 of file decodable-matrix.h.
Referenced by SingleUtteranceNnet2DecoderThreaded::RunNnetEvaluationInternal().
|
inline |
Definition at line 169 of file decodable-matrix.h.
Referenced by SingleUtteranceNnet2DecoderThreaded::RunNnetEvaluationInternal().
Returns true if this is the last frame.
Frames are zero-based, so the first frame is zero. IsLastFrame(-1) will return false, unless the file is empty (which is a case that I'm not sure all the code will handle, so be careful). Caution: the behavior of this function in an online setting is being changed somewhat. In future it may return false in cases where we haven't yet decided to terminate decoding, but later true if we decide to terminate decoding. The plan in future is to rely more on NumFramesReady(), and in future, IsLastFrame() would always return false in an online-decoding setting, and would only return true in a decoding-from-matrix setting where we want to allow the last delta or LDA features to be flushed out for compatibility with the baseline setup.
Implements DecodableInterface.
Definition at line 175 of file decodable-matrix.h.
References KALDI_ASSERT, and DecodableMatrixScaledMapped::NumFramesReady().
Referenced by SingleUtteranceNnet2DecoderThreaded::RunDecoderSearchInternal().
|
private |
Returns the log likelihood, which will be negated in the decoder.
The "frame" starts from zero. You should verify that NumFramesReady() > frame before calling this.
Implements DecodableInterface.
Definition at line 180 of file decodable-matrix.h.
References DecodableMatrixScaledMapped::trans_model_, and TransitionModel::TransitionIdToPdfFast().
|
inlinevirtual |
The call NumFramesReady() will return the number of frames currently available for this decodable object.
This is for use in setups where you don't want the decoder to block while waiting for input. This is newly added as of Jan 2014, and I hope, going forward, to rely on this mechanism more than IsLastFrame to know when to stop decoding.
Reimplemented from DecodableInterface.
Definition at line 171 of file decodable-matrix.h.
Referenced by SingleUtteranceNnet2DecoderThreaded::RunDecoderSearchInternal().
|
inlinevirtual |
Returns the number of states in the acoustic model (they will be indexed one-based, i.e.
from 1 to NumIndices(); this is for compatibility with OpenFst).
Implements DecodableInterface.
Definition at line 190 of file decodable-matrix.h.
References TransitionModel::NumTransitionIds(), and DecodableMatrixScaledMapped::trans_model_.
|
private |
Definition at line 197 of file decodable-matrix.h.
|
private |
Definition at line 198 of file decodable-matrix.h.
Definition at line 196 of file decodable-matrix.h.
|
private |
Definition at line 205 of file decodable-matrix.h.
|
private |
Definition at line 206 of file decodable-matrix.h.
|
private |
Definition at line 195 of file decodable-matrix.h.