Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
TensorSpeech
GitHub Repository: TensorSpeech/TensorFlowTTS
Path: blob/master/examples/cpptflite/src/VocoderTF.cpp
1559 views
1
#include "VocoderTF.h"
2
3
std::vector<float> VocoderTF::infer(const MelGenData mel)
4
{
5
std::vector<float> audio;
6
7
interpreter->ResizeInputTensor(inputIndex, mel.melShape);
8
TFLITE_MINIMAL_CHECK(interpreter->AllocateTensors() == kTfLiteOk);
9
10
float* melDataPtr = interpreter->typed_input_tensor<float>(inputIndex);
11
memcpy(melDataPtr, mel.melData, mel.bytes);
12
13
TFLITE_MINIMAL_CHECK(interpreter->Invoke() == kTfLiteOk);
14
15
TfLiteTensor* audioTensor = interpreter->tensor(outputIndex);
16
17
float* outputPtr = interpreter->typed_output_tensor<float>(0);
18
19
int32_t audio_len = audioTensor->bytes / float_size;
20
21
for (int i=0; i<audio_len; ++i)
22
{
23
audio.push_back(outputPtr[i]);
24
}
25
26
return audio;
27
}
28
29