| 62 | } |
| 63 | |
| 64 | TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { |
| 65 | auto* params = reinterpret_cast<TfLiteMfccParams*>(node->user_data); |
| 66 | |
| 67 | TF_LITE_ENSURE_EQ(context, NumInputs(node), 2); |
| 68 | TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); |
| 69 | |
| 70 | const TfLiteTensor* input_wav = GetInput(context, node, kInputTensorWav); |
| 71 | const TfLiteTensor* input_rate = GetInput(context, node, kInputTensorRate); |
| 72 | TfLiteTensor* output = GetOutput(context, node, kOutputTensor); |
| 73 | |
| 74 | TF_LITE_ENSURE_EQ(context, NumDimensions(input_wav), 3); |
| 75 | TF_LITE_ENSURE_EQ(context, NumElements(input_rate), 1); |
| 76 | |
| 77 | TF_LITE_ENSURE_EQ(context, output->type, kTfLiteFloat32); |
| 78 | TF_LITE_ENSURE_EQ(context, input_wav->type, output->type); |
| 79 | TF_LITE_ENSURE_EQ(context, input_rate->type, kTfLiteInt32); |
| 80 | |
| 81 | TfLiteIntArray* output_size = TfLiteIntArrayCreate(3); |
| 82 | output_size->data[0] = input_wav->dims->data[0]; |
| 83 | output_size->data[1] = input_wav->dims->data[1]; |
| 84 | output_size->data[2] = params->dct_coefficient_count; |
| 85 | |
| 86 | return context->ResizeTensor(context, output, output_size); |
| 87 | } |
| 88 | |
| 89 | // Input is a single squared-magnitude spectrogram frame. The input spectrum |
| 90 | // is converted to linear magnitude and weighted into bands using a |
nothing calls this directly
no test coverage detected