28 for (
int32 i = 0;
i < num_fft_bins;
i++) {
37 int32 output_length = signal_length + filter_length - 1;
40 for (
int32 i = 0;
i < signal_length;
i++) {
41 for (
int32 j = 0;
j < filter_length;
j++) {
42 signal_padded(
i +
j) += (*signal)(
i) * filter(
j);
45 signal->
Resize(output_length);
53 int32 output_length = signal_length + filter_length - 1;
56 KALDI_VLOG(1) <<
"fft_length for full signal convolution is " << fft_length;
61 filter_padded.
Range(0, filter_length).CopyFromVec(filter);
65 signal_padded.
Range(0, signal_length).CopyFromVec(*signal);
71 signal_padded.
Scale(1.0 / fft_length);
73 signal->
Resize(output_length);
80 int32 output_length = signal_length + filter_length - 1;
83 KALDI_VLOG(1) <<
"Length of the filter is " << filter_length;
86 KALDI_VLOG(1) <<
"Best FFT length is " << fft_length;
88 int32 block_length = fft_length - filter_length + 1;
89 KALDI_VLOG(1) <<
"Block size is " << block_length;
93 filter_padded.
Range(0, filter_length).CopyFromVec(filter);
100 for (
int32 po = 0; po < output_length; po += block_length) {
102 int32 process_length = std::min(block_length, output_length - po);
104 signal_block_padded.
Range(0, process_length).CopyFromVec(signal->
Range(po, process_length));
111 signal_block_padded.
Scale(1.0 / fft_length);
114 if (po + block_length < output_length) {
115 signal->
Range(po, block_length).CopyFromVec(signal_block_padded.
Range(0, block_length));
116 signal->
Range(po, filter_length - 1).AddVec(1.0, temp_pad);
117 temp_pad.
CopyFromVec(signal_block_padded.
Range(block_length, filter_length - 1));
119 signal->
Range(po, output_length - po).CopyFromVec(
120 signal_block_padded.
Range(0, output_length - po));
121 if (filter_length - 1 < output_length - po)
122 signal->
Range(po, filter_length - 1).AddVec(1.0, temp_pad);
124 signal->
Range(po, output_length - po).AddVec(1.0, temp_pad.
Range(0, output_length - po));
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
int32 RoundUpToNearestPowerOfTwo(int32 n)
void Resize(MatrixIndexT length, MatrixResizeType resize_type=kSetZero)
Set vector to a specified size (can be zero).
void FFTbasedConvolveSignals(const Vector< BaseFloat > &filter, Vector< BaseFloat > *signal)
void FFTbasedBlockConvolveSignals(const Vector< BaseFloat > &filter, Vector< BaseFloat > *signal)
void CopyFromVec(const VectorBase< Real > &v)
Copy data from another vector (must match own size).
void ElementwiseProductOfFft(const Vector< BaseFloat > &a, Vector< BaseFloat > *b)
Real * Data()
Returns a pointer to the start of the vector's data.
void ComplexMul(const Real &a_re, const Real &a_im, Real *b_re, Real *b_im)
ComplexMul implements, inline, the complex multiplication b *= a.
MatrixIndexT Dim() const
Returns the dimension of the vector.
void Scale(Real alpha)
Multiplies all elements by this constant.
A class representing a vector.
void ConvolveSignals(const Vector< BaseFloat > &filter, Vector< BaseFloat > *signal)
void SetZero()
Set vector to all zeros.
void Compute(Real *x, bool forward)
If forward == true, this function transforms from a sequence of N real points to its complex fourier ...
SubVector< Real > Range(const MatrixIndexT o, const MatrixIndexT l)
Returns a sub-vector of a vector (a range of elements).