20 #ifndef KALDI_FEAT_FEATURE_COMMON_INL_H_ 21 #define KALDI_FEAT_FEATURE_COMMON_INL_H_ 35 BaseFloat new_sample_freq = computer_.GetFrameOptions().samp_freq;
36 if (sample_freq == new_sample_freq) {
37 Compute(wave, vtln_warp, output);
39 if (new_sample_freq < sample_freq &&
40 ! computer_.GetFrameOptions().allow_downsample)
41 KALDI_ERR <<
"Waveform and config sample Frequency mismatch: " 42 << sample_freq <<
" .vs " << new_sample_freq
43 <<
" (use --allow-downsample=true to allow " 44 <<
" downsampling the waveform).";
45 else if (new_sample_freq > sample_freq &&
46 ! computer_.GetFrameOptions().allow_upsample)
47 KALDI_ERR <<
"Waveform and config sample Frequency mismatch: " 48 << sample_freq <<
" .vs " << new_sample_freq
49 <<
" (use --allow-upsample=true option to allow " 50 <<
" upsampling the waveform).";
54 new_sample_freq, &resampled_wave);
55 Compute(resampled_wave, vtln_warp, output);
66 cols_out = computer_.Dim();
71 output->
Resize(rows_out, cols_out);
73 bool use_raw_log_energy = computer_.NeedRawLogEnergy();
74 for (
int32 r = 0; r < rows_out; r++) {
77 feature_window_function_, &window,
78 (use_raw_log_energy ? &raw_log_energy : NULL));
81 computer_.Compute(raw_log_energy, vtln_warp, &window, &output_row);
94 temp.
Compute(wave, vtln_warp, output);
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void Compute(const VectorBase< BaseFloat > &wave, BaseFloat vtln_warp, Matrix< BaseFloat > *output)
void ResampleWaveform(BaseFloat orig_freq, const VectorBase< BaseFloat > &wave, BaseFloat new_freq, Vector< BaseFloat > *new_wave)
Downsample or upsample a waveform.
void ComputeFeatures(const VectorBase< BaseFloat > &wave, BaseFloat sample_freq, BaseFloat vtln_warp, Matrix< BaseFloat > *output)
Computes the features for one file (one sequence of features).
void ExtractWindow(int64 sample_offset, const VectorBase< BaseFloat > &wave, int32 f, const FrameExtractionOptions &opts, const FeatureWindowFunction &window_function, Vector< BaseFloat > *window, BaseFloat *log_energy_pre_window)
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...
MatrixIndexT Dim() const
Returns the dimension of the vector.
A class representing a vector.
#define KALDI_ASSERT(cond)
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).
This templated class is intended for offline feature extraction, i.e.
Provides a vector abstraction class.
Represents a non-allocating general vector which can be defined as a sub-vector of higher-level vecto...