Deepspeech: Building Native Client for Android

Created on 8 Feb 2018  路  13Comments  路  Source: mozilla/DeepSpeech

For support and discussions, please use our Discourse forums.

If you've found a bug, or have a feature request, then please create an issue with the following information:

  • Have I written custom code (as opposed to running examples on an unmodified clone of the repository):
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • TensorFlow installed from (our builds, or upstream TensorFlow):
  • TensorFlow version (use command below):
  • Python version:
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:
  • Exact command to reproduce:

You can obtain the TensorFlow version with

python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"

Hi I'd like to build and run deepspeech on Android. I was wondering if you guys could help with instructions for building the Native Client for Android (armebi-v7a).

Thank you :)

foundations

Most helpful comment

I built TF and DeepSpeech for Android. Still have some problems with model loading. Will try to fix and test on next week. But IMO right direction will be adopt model to TF Lite. #1224

All 13 comments

TensorFlow does support Android, but we are not yet supporting building that. It should not be that hard, patches are welcome :)

I built TF and DeepSpeech for Android. Still have some problems with model loading. Will try to fix and test on next week. But IMO right direction will be adopt model to TF Lite. #1224

@farwayer Feel free to share any issue you had to achieve that. Integrating Android build should require making changes to https://github.com/mozilla/tensorflow TaskCluster build as well, and then DeepSpeech repo.

@farwayer Awesome, would you mind sharing your bazel BUILD file for DeepSpeech on Android once you test? Also, which version of TF did you build?

@alirezadir For now I'm using cmake with android-ndk inside android project. I'm not familiar with bazel. Will dig into if I have free time.

@farwayer Oh I see. I was originally thinking to do with cmake, but thought it might be more straightforward to do with bazel, as deepspeech already comes with bazel build scripts, but have not been successful yet. I have only been able so far to build libdeepspeech_utils.so out of the native client.
Would you mind sharing instructions on building deepspeech with cmake and ndk (i.e. the CMakeLists etc)?

@farwayer @alirezadir This discussion is interesting, but it would be better if we could keep this issue for tracking the work on the feature, and share experiences and hacking on a Discourse thread: https://discourse.mozilla.org/c/deep-speech :)

@lissyx Yes I think this is not only interesting, but also an important enhancement to be added to deepspeech client, to enable running on embedded systems (esp. Android devices). Since you guys currently do not support Android, I would like to ask if we keep this open, to come up with a build for Android as well. This is also very relevant to issue #1224., which has been tagged as a priority 1 enhancement. I think TF lite support without Android support would not make sense.

@lissyx I can build DeepSpeech with Android NDK 16 and libc++ only. The problem is Android NDK 16 is not supported by bazel now https://github.com/bazelbuild/bazel/issues/4068. So let's wait for it to be fixed.

I've flagged tflite for this exact reason, so yes we keep this issue open. We will work on it as soon as we can, or if anyone feels like hacking we can do that as well and take PR :-)

@lissyx I can build DeepSpeech with Android NDK 16 and libc++ only. The problem is Android NDK 16 is not supported by bazel now bazelbuild/bazel#4068. So let's wait for it to be fixed.

$ LD_LIBRARY_PATH=. ./deepspeech --model output_graph_toco-r1.12.tflite --alphabet alphabet.txt --audio LDC93S1.wav -t                                                                                                         
WARNING: linker: Warning: "/data/local/tmp/libdeepspeech.so" unused DT entry: DT_RPATH (type 0xf arg 0x766a) (ignoring)
DeepSpeech: v0.4.0-alpha.0-8-g19d92e6
audio_format=1
num_channels=1
sample_rate=16000
bits_per_sample=16
res.buffer_size=93594
cpu_time_invoke=0.549066
cpu_time_invoke_all=0.549066
cpu_time_invoke=0.489632
cpu_time_invoke_all=1.0387
cpu_time_invoke=0.489618
cpu_time_invoke_all=1.52832
cpu_time_invoke=0.48704
cpu_time_invoke_all=2.01536
cpu_time_invoke=0.488559
cpu_time_invoke_all=2.50392
cpu_time_invoke=0.489055
cpu_time_invoke_all=2.99297
cpu_time_invoke=0.490009
cpu_time_invoke_all=3.48298
cpu_time_invoke=0.491847
cpu_time_invoke_all=3.97483
cpu_time_invoke=0.492275
cpu_time_invoke_all=4.4671
cpu_time_invoke=0.492672
cpu_time_invoke_all=4.95977
cpu_time_decode=1.00409
r r r r r r r r r r r r r r r
cpu_time_overall=5.97932

So, now one can build and run native client on some Android devices.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings