-
Couldn't load subscription status.
- Fork 4.1k
File descriptor support for Android/Java/JNI #3507
Description
I would like the Android/Java/JNI bindings to support file descriptors. Currently, they only support paths.
I am using Android's SAF (the OS's graphical file picker) to open the model and scorer files. It avoids asking for invasive permissions but returns a file descriptor instead of a path. On Android 10, I could just convert the file descriptor into a path using the expression "/proc/self/fd/" + fd. After updating to Android 11, this fails with a permission denied error. A workaround might be to request for access to the entire internal storage, but this is not ideal for privacy reasons.
I heard that dup works while fopen doesn't. This leads to two possible solutions:
- Add another constructor that accepts an
intto use as a file descriptor, and pass that all the way into native code - Have the existing constructor detect whether the path starts with
/proc/self/fd/, and if it does, use the existing file descriptor instead of opening a file
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): WIP Overhaul Android app DeepSpeech-examples#101
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Android 11 Beta 1 on OnePlus 7 Pro
- TensorFlow installed from (our builds, or upstream TensorFlow): N/A
- TensorFlow version (use command below): N/A
- Python version: N/A
- Bazel version (if compiling from source): N/A
- GCC/Compiler version (if compiling from source): N/A
- CUDA/cuDNN version: N/A
- GPU model and memory: N/A
- Exact command to reproduce: N/A
- Gradle dependency:
implementation 'org.mozilla.deepspeech:libdeepspeech:0.9.2'