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

Method Initialize

tensorflow/core/kernels/mfcc_dct.cc:25–58  ·  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 LOG(ERROR) << "Coefficient count must be positive.";
31 return false;
32 }
33
34 if (input_length < 1) {
35 LOG(ERROR) << "Input length must be positive.";
36 return false;
37 }
38
39 if (coefficient_count_ > input_length_) {
40 LOG(ERROR) << "Coefficient count must be less than or equal to "
41 << "input length.";
42 return false;
43 }
44
45 cosines_.resize(coefficient_count_);
46 double fnorm = sqrt(2.0 / input_length_);
47 // Some platforms don't have M_PI, so define a local constant here.
48 const double pi = std::atan(1) * 4;
49 double arg = pi / input_length_;
50 for (int i = 0; i < coefficient_count_; ++i) {
51 cosines_[i].resize(input_length_);
52 for (int j = 0; j < input_length_; ++j) {
53 cosines_[i][j] = fnorm * cos(i * arg * (j + 0.5));
54 }
55 }
56 initialized_ = true;
57 return true;
58}
59
60void MfccDct::Compute(const std::vector<double> &input,
61 std::vector<double> *output) const {

Callers

nothing calls this directly

Calls 4

atanClass · 0.85
sqrtClass · 0.70
cosClass · 0.70
resizeMethod · 0.45

Tested by

no test coverage detected