online-feature-itf.h
Go to the documentation of this file.
1 // itf/online-feature-itf.h
2 
3 // Copyright 2013 Johns Hopkins University (author: Daniel Povey)
4 
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 
20 #ifndef KALDI_ITF_ONLINE_FEATURE_ITF_H_
21 #define KALDI_ITF_ONLINE_FEATURE_ITF_H_ 1
22 #include "base/kaldi-common.h"
23 #include "matrix/matrix-lib.h"
24 
25 namespace kaldi {
28 
50  public:
51  virtual int32 Dim() const = 0;
52 
56  virtual int32 NumFramesReady() const = 0;
57 
67  virtual bool IsLastFrame(int32 frame) const = 0;
68 
75  virtual void GetFrame(int32 frame, VectorBase<BaseFloat> *feat) = 0;
76 
77 
82  virtual void GetFrames(const std::vector<int32> &frames,
83  MatrixBase<BaseFloat> *feats) {
84  KALDI_ASSERT(static_cast<int32>(frames.size()) == feats->NumRows());
85  for (size_t i = 0; i < frames.size(); i++) {
86  SubVector<BaseFloat> feat(*feats, i);
87  GetFrame(frames[i], &feat);
88  }
89  }
90 
91 
92  // Returns frame shift in seconds. Helps to estimate duration from frame
93  // counts.
94  virtual BaseFloat FrameShiftInSeconds() const = 0;
95 
100 
101 };
102 
103 
107  public:
111  virtual void AcceptWaveform(BaseFloat sampling_rate,
112  const VectorBase<BaseFloat> &waveform) = 0;
113 
118  virtual void InputFinished() = 0;
119 };
120 
121 
123 } // namespace Kaldi
124 
125 #endif // KALDI_ITF_ONLINE_FEATURE_ITF_H_
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
Base class which provides matrix operations not involving resizing or allocation. ...
Definition: kaldi-matrix.h:49
virtual ~OnlineFeatureInterface()
Virtual destructor.
virtual void GetFrame(int32 frame, VectorBase< BaseFloat > *feat)=0
Gets the feature vector for this frame.
kaldi::int32 int32
virtual void GetFrames(const std::vector< int32 > &frames, MatrixBase< BaseFloat > *feats)
This is like GetFrame() but for a collection of frames.
virtual bool IsLastFrame(int32 frame) const =0
Returns true if this is the last frame.
virtual BaseFloat FrameShiftInSeconds() const =0
Add a virtual class for "source" features such as MFCC or PLP or pitch features.
#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
OnlineFeatureInterface is an interface for online feature processing (it is also usable in the offlin...
Provides a vector abstraction class.
Definition: kaldi-vector.h:41
virtual int32 NumFramesReady() const =0
returns the feature dimension.
Represents a non-allocating general vector which can be defined as a sub-vector of higher-level vecto...
Definition: kaldi-vector.h:501
virtual int32 Dim() const =0