diff --git a/native_client/tflitemodelstate.cc b/native_client/tflitemodelstate.cc index 8d780fe2a6..b72b1fa1ae 100755 --- a/native_client/tflitemodelstate.cc +++ b/native_client/tflitemodelstate.cc @@ -164,7 +164,10 @@ TFLiteModelState::init(const std::string &model_string, bool init_from_bytes) } if (init_from_bytes){ - fbmodel_ = tflite::FlatBufferModel::BuildFromBuffer(model_string.c_str(), model_string.size_t); + char *tmp_buffer = new char[model_string.size()]; + std::copy(model_string.begin(), model_string.end(), tmp_buffer); + // Using c_str does not work + fbmodel_ = tflite::FlatBufferModel::VerifyAndBuildFromBuffer(tmp_buffer,model_string.size()); if (!fbmodel_) { std::cerr << "Error at reading model buffer " << std::endl; return DS_ERR_FAIL_INIT_MMAP; @@ -177,7 +180,6 @@ TFLiteModelState::init(const std::string &model_string, bool init_from_bytes) } } - tflite::ops::builtin::BuiltinOpResolver resolver; tflite::InterpreterBuilder(*fbmodel_, resolver)(&interpreter_); if (!interpreter_) {