Path: blob/master/examples/cpptflite/src/VocoderTF.cpp
1559 views
#include "VocoderTF.h"12std::vector<float> VocoderTF::infer(const MelGenData mel)3{4std::vector<float> audio;56interpreter->ResizeInputTensor(inputIndex, mel.melShape);7TFLITE_MINIMAL_CHECK(interpreter->AllocateTensors() == kTfLiteOk);89float* melDataPtr = interpreter->typed_input_tensor<float>(inputIndex);10memcpy(melDataPtr, mel.melData, mel.bytes);1112TFLITE_MINIMAL_CHECK(interpreter->Invoke() == kTfLiteOk);1314TfLiteTensor* audioTensor = interpreter->tensor(outputIndex);1516float* outputPtr = interpreter->typed_output_tensor<float>(0);1718int32_t audio_len = audioTensor->bytes / float_size;1920for (int i=0; i<audio_len; ++i)21{22audio.push_back(outputPtr[i]);23}2425return audio;26}272829