DecodableMapped Class Reference

#include <decodable-mapped.h>

Inheritance diagram for DecodableMapped:
Collaboration diagram for DecodableMapped:

Public Member Functions

 DecodableMapped (const std::vector< int32 > &index_map, DecodableInterface *d)
 
virtual BaseFloat LogLikelihood (int32 frame, int32 state_index)
 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 bool IsLastFrame (int32 frame) const
 Returns true if this is the last frame. More...
 
- Public Member Functions inherited from DecodableInterface
virtual int32 NumFramesReady () const
 The call NumFramesReady() will return the number of frames currently available for this decodable object. More...
 
virtual ~DecodableInterface ()
 

Private Member Functions

 KALDI_DISALLOW_COPY_AND_ASSIGN (DecodableMapped)
 

Private Attributes

std::vector< int32index_map_
 
DecodableInterfacedecodable_
 

Detailed Description

Definition at line 36 of file decodable-mapped.h.

Constructor & Destructor Documentation

◆ DecodableMapped()

DecodableMapped ( const std::vector< int32 > &  index_map,
DecodableInterface d 
)
inline

Definition at line 38 of file decodable-mapped.h.

38  :
39  index_map_(index_map), decodable_(d) { }
DecodableInterface * decodable_
std::vector< int32 > index_map_

Member Function Documentation

◆ IsLastFrame()

virtual bool IsLastFrame ( int32  frame) const
inlinevirtual

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 52 of file decodable-mapped.h.

References DecodableMapped::decodable_, and DecodableInterface::IsLastFrame().

52  {
53  // We require all the decodables have the same #frames. We don't check this though.
54  return decodable_->IsLastFrame(frame);
55  }
virtual bool IsLastFrame(int32 frame) const =0
Returns true if this is the last frame.
DecodableInterface * decodable_

◆ KALDI_DISALLOW_COPY_AND_ASSIGN()

KALDI_DISALLOW_COPY_AND_ASSIGN ( DecodableMapped  )
private

◆ LogLikelihood()

virtual BaseFloat LogLikelihood ( int32  frame,
int32  index 
)
inlinevirtual

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 43 of file decodable-mapped.h.

References DecodableMapped::decodable_, DecodableMapped::index_map_, KALDI_ASSERT, and DecodableInterface::LogLikelihood().

43  {
44  KALDI_ASSERT(static_cast<size_t>(state_index) < index_map_.size());
45  return decodable_->LogLikelihood(frame, index_map_[state_index]);
46  }
DecodableInterface * decodable_
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
virtual BaseFloat LogLikelihood(int32 frame, int32 index)=0
Returns the log likelihood, which will be negated in the decoder.
std::vector< int32 > index_map_

◆ NumIndices()

virtual int32 NumIndices ( ) const
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 50 of file decodable-mapped.h.

References DecodableMapped::index_map_.

50 { return static_cast<int32>(index_map_.size()) - 1; }
kaldi::int32 int32
std::vector< int32 > index_map_

Member Data Documentation

◆ decodable_

DecodableInterface* decodable_
private

◆ index_map_

std::vector<int32> index_map_
private

The documentation for this class was generated from the following file: