From 49ccf7f33b603350d0ed88c300dbcea42b8276ce Mon Sep 17 00:00:00 2001 From: Alexandre Lissy Date: Wed, 12 Dec 2018 12:05:11 +0100 Subject: [PATCH] Enable TFLite on Android --- native_client/deepspeech.cc | 15 +++++++++++++++ native_client/deepspeech.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/native_client/deepspeech.cc b/native_client/deepspeech.cc index 676586c7..f2fd6cdb 100644 --- a/native_client/deepspeech.cc +++ b/native_client/deepspeech.cc @@ -28,6 +28,16 @@ #include "ctcdecode/ctc_beam_search_decoder.h" +#ifdef __ANDROID__ +#include +#define LOG_TAG "libdeepspeech" +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) +#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) +#else +#define LOGD(...) +#define LOGE(...) +#endif // __ANDROID__ + //TODO: infer batch size from model/use dynamic batch size constexpr unsigned int BATCH_SIZE = 1; @@ -778,7 +788,12 @@ DS_AudioToInputVector(const short* aBuffer, void DS_PrintVersions() { +#ifndef __ANDROID__ std::cerr << "TensorFlow: " << tf_git_version() << std::endl; std::cerr << "DeepSpeech: " << ds_git_version() << std::endl; +#else + LOGE("DeepSpeech: %s", ds_git_version()); + LOGD("DeepSpeech: %s", ds_git_version()); +#endif } diff --git a/native_client/deepspeech.h b/native_client/deepspeech.h index ea054255..c36997df 100644 --- a/native_client/deepspeech.h +++ b/native_client/deepspeech.h @@ -1,6 +1,10 @@ #ifndef DEEPSPEECH_H #define DEEPSPEECH_H +#ifdef __ANDROID__ +#define USE_TFLITE +#endif + #ifndef SWIG #define DEEPSPEECH_EXPORT __attribute__ ((visibility("default"))) #else