22 #ifndef KALDI_ONLINE_ONLINE_FEAT_INPUT_H_ 23 #define KALDI_ONLINE_ONLINE_FEAT_INPUT_H_ 25 #if !defined(_MSC_VER) 26 #include <sys/types.h> 27 #include <sys/socket.h> 28 #include <netinet/in.h> 29 #include <arpa/inet.h> 89 : input_(input), cmn_window_(cmn_window), min_window_(min_window),
90 history_(cmn_window + 1, input->
Dim()), t_in_(0), t_out_(0),
91 sum_(input->
Dim()) {
KALDI_ASSERT(cmn_window >= min_window && min_window > 0); }
95 virtual int32 Dim()
const {
return input_->Dim(); }
114 bool more_data)
const;
151 std::vector<Matrix<BaseFloat>* >
data_;
155 #if !defined(_MSC_VER) 191 int32 right_context);
195 virtual int32 Dim()
const {
return linear_transform_.NumRows(); }
208 int32 context_window,
239 virtual int32 Dim()
const {
return input_dim_ * (opts_.order + 1); }
279 const int32 frame_size,
const int32 frame_shift,
280 const bool snip_edges =
true);
282 virtual int32 Dim()
const {
return extractor_->Dim(); }
303 : source_(au_src), extractor_(fe),
304 frame_size_(frame_size), frame_shift_(frame_shift) {
313 template<
class E>
bool 317 KALDI_WARN <<
"No feature vectors requested?!";
330 CopyFromVec(read_samples);
338 int32 remaining_len = all_samples.Dim() - offset;
341 if (remaining_len > 0)
343 extractor_->Compute(all_samples, 1.0, output);
359 opts->
Register(
"batch-size", &batch_size,
360 "Number of feature vectors processed w/o interruption");
361 opts->
Register(
"num-tries", &num_tries,
362 "Number of successive repetitions of timeout before we " 374 opts_(opts), input_(input), feat_dim_(input->
Dim()),
375 feat_offset_(0), finished_(false) { }
377 bool IsValidFrame (
int32 frame);
387 void GetNextFeatures();
401 #endif // KALDI_ONLINE_ONLINE_FEAT_INPUT_H_
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Matrix< BaseFloat > feat_matrix_
OnlineFeatureMatrix(const OnlineFeatureMatrixOptions &opts, OnlineFeatInputItf *input)
virtual bool Read(Vector< BaseFloat > *data)=0
Base class which provides matrix operations not involving resizing or allocation. ...
#define KALDI_DISALLOW_COPY_AND_ASSIGN(type)
OnlineFeatInputItf * input_
virtual void Register(const std::string &name, bool *ptr, const std::string &doc)=0
OnlineFeatureMatrixOptions()
int32 NumFrames(int64 num_samples, const FrameExtractionOptions &opts, bool flush)
This function returns the number of frames that we can extract from a wave file with the given number...
const OnlineFeatureMatrixOptions opts_
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void SpliceFrames(const MatrixBase< BaseFloat > &input_features, int32 left_context, int32 right_context, Matrix< BaseFloat > *output_features)
void Resize(const MatrixIndexT r, const MatrixIndexT c, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride)
Sets matrix to a specified size (zero is OK as long as both r and c are zero).
void Register(OptionsItf *opts)
Provides a vector abstraction class.
Represents a non-allocating general vector which can be defined as a sub-vector of higher-level vecto...
SubVector< Real > Range(const MatrixIndexT o, const MatrixIndexT l)
Returns a sub-vector of a vector (a range of elements).