MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Initialize

Method Initialize

tensorflow/lite/kernels/internal/mfcc_dct.cc:25–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23MfccDct::MfccDct() : initialized_(false) {}
24
25bool MfccDct::Initialize(int input_length, int coefficient_count) {
26 coefficient_count_ = coefficient_count;
27 input_length_ = input_length;
28
29 if (coefficient_count_ < 1) {
30 return false;
31 }
32
33 if (input_length < 1) {
34 return false;
35 }
36
37 if (coefficient_count_ > input_length_) {
38 return false;
39 }
40
41 cosines_.resize(coefficient_count_);
42 double fnorm = sqrt(2.0 / input_length_);
43 // Some platforms don't have M_PI, so define a local constant here.
44 const double pi = atan(1.0) * 4.0;
45 double arg = pi / input_length_;
46 for (int i = 0; i < coefficient_count_; ++i) {
47 cosines_[i].resize(input_length_);
48 for (int j = 0; j < input_length_; ++j) {
49 cosines_[i][j] = fnorm * cos(i * arg * (j + 0.5));
50 }
51 }
52 initialized_ = true;
53 return true;
54}
55
56void MfccDct::Compute(const std::vector<double> &input,
57 std::vector<double> *output) const {

Callers

nothing calls this directly

Calls 4

atanClass · 0.85
sqrtFunction · 0.50
cosFunction · 0.50
resizeMethod · 0.45

Tested by

no test coverage detected