Enable TFLite on Android

This commit is contained in:
Alexandre Lissy 2018-12-12 12:05:11 +01:00
parent 69aa316c88
commit 49ccf7f33b
2 changed files with 19 additions and 0 deletions

View File

@ -28,6 +28,16 @@
#include "ctcdecode/ctc_beam_search_decoder.h" #include "ctcdecode/ctc_beam_search_decoder.h"
#ifdef __ANDROID__
#include <android/log.h>
#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 //TODO: infer batch size from model/use dynamic batch size
constexpr unsigned int BATCH_SIZE = 1; constexpr unsigned int BATCH_SIZE = 1;
@ -778,7 +788,12 @@ DS_AudioToInputVector(const short* aBuffer,
void void
DS_PrintVersions() { DS_PrintVersions() {
#ifndef __ANDROID__
std::cerr << "TensorFlow: " << tf_git_version() << std::endl; std::cerr << "TensorFlow: " << tf_git_version() << std::endl;
std::cerr << "DeepSpeech: " << ds_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
} }

View File

@ -1,6 +1,10 @@
#ifndef DEEPSPEECH_H #ifndef DEEPSPEECH_H
#define DEEPSPEECH_H #define DEEPSPEECH_H
#ifdef __ANDROID__
#define USE_TFLITE
#endif
#ifndef SWIG #ifndef SWIG
#define DEEPSPEECH_EXPORT __attribute__ ((visibility("default"))) #define DEEPSPEECH_EXPORT __attribute__ ((visibility("default")))
#else #else