-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standalone Java bindings #3503
base: master
Are you sure you want to change the base?
Standalone Java bindings #3503
Changes from all commits
8d515f5
662de59
2d8f9ee
86a3c52
a15aed6
07ba928
ff12a73
6bbc27a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches/build_file_checksums.ser | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
#Native libs | ||
libdeepspeech_android/libs/* | ||
!libdeepspeech_android/libs/.gitignore | ||
libdeepspeech_android/*.so | ||
|
||
#Gradle | ||
.gradle/ | ||
|
||
#Make/CMake | ||
Makefile/ | ||
|
||
#SWIG | ||
jni/*.cpp | ||
jni/*.o | ||
|
||
#Collected files by make | ||
build/ | ||
|
||
#Autogenerated java files by SWIG | ||
libdeepspeech_android/src/main/java/org/deepspeech/libdeepspeech/*.java | ||
!libdeepspeech_android/src/main/java/org/deepspeech/libdeepspeech/DeepSpeechModel.java | ||
!libdeepspeech_android/src/main/java/org/deepspeech/libdeepspeech/DeepSpeechStreamingState.java |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,73 @@ | ||
.PHONY: clean apk-clean | ||
.PHONY: clean android-clean jre jre-prepare jre-libdeepspeech-jni jre-gradle jre-collect jre-clean android-prepare | ||
|
||
include ../definitions.mk | ||
|
||
ARCHS := $(shell grep 'ABI_FILTERS' libdeepspeech/gradle.properties | cut -d'=' -f2 | sed -e 's/;/ /g') | ||
ARCHS := $(shell grep 'ABI_FILTERS' libdeepspeech_android/gradle.properties | cut -d'=' -f2 | sed -e 's/;/ /g') | ||
GRADLE ?= ./gradlew | ||
|
||
all: apk | ||
all: android jre | ||
standalone: jre | ||
|
||
clean: apk-clean | ||
clean: android-clean jre-clean | ||
rm -rf *.java jni/deepspeech_wrap.cpp | ||
|
||
apk-clean: | ||
android-clean: | ||
$(GRADLE) clean | ||
rm -rf settings.gradle | ||
|
||
libs-clean: | ||
rm -fr libdeepspeech/libs/*/libdeepspeech.so | ||
jre-clean: | ||
rm -f build.gradle | ||
rm -f jni/deepspeech_wrap.cpp jni/deepspeech_wrap.o | ||
rm -rf libdeepspeech_jre/cmake_install.cmake libdeepspeech_jre/CMakeCache.txt libdeepspeech_jre/Makefile libdeepspeech_jre/CMakeFiles/ | ||
rm -rf libdeepspeech_jre/build/ | ||
rm -rf settings.gradle | ||
|
||
libdeepspeech/libs/%/libdeepspeech.so: | ||
-mkdir libdeepspeech/libs/$*/ | ||
cp ${TFDIR}/bazel-out/$*-*/bin/native_client/libdeepspeech.so libdeepspeech/libs/$*/ | ||
libdeepspeech_jre/libs/%/libdeepspeech.so: | ||
-mkdir libdeepspeech_jre/libs/$*/ | ||
cp ${TFDIR}/bazel-out/$*-*/bin/native_client/libdeepspeech.so libdeepspeech_jre/libs/$*/ | ||
|
||
apk: apk-clean bindings $(patsubst %,libdeepspeech/libs/%/libdeepspeech.so,$(ARCHS)) | ||
libdeepspeech_android/libs/%/libdeepspeech.so: | ||
-mkdir libdeepspeech_android/libs/$*/ | ||
cp ${TFDIR}/bazel-out/$*-*/bin/native_client/libdeepspeech.so libdeepspeech_android/libs/$*/ | ||
|
||
android-prepare: | ||
cp build.gradle.android build.gradle | ||
cp libdeepspeech_android/settings.gradle settings.gradle | ||
|
||
android: android-prepare android-clean bindings $(patsubst %,libdeepspeech/libs/%/libdeepspeech.so,$(ARCHS)) | ||
$(GRADLE) build | ||
|
||
jre: jre-prepare jre-collect jre-restore-makefile jre-clean | ||
jre-prepare: $(patsubst %,libdeepspeech_jre/libs/%/libdeepspeech.so,$(ARCHS)) | ||
cp Makefile Makefile.original | ||
cp build.gradle.standalone build.gradle | ||
cp libdeepspeech_jre/settings.gradle ./settings.gradle | ||
sed -i 's|__JAVA_HOME__|'${JAVA_HOME}'|g' libdeepspeech_jre/CMakeLists.txt | ||
|
||
jre-libdeepspeech-jni: bindings | ||
cd libdeepspeech_jre; \ | ||
cmake .; \ | ||
$(MAKE) | ||
|
||
jre-gradle: jre-libdeepspeech-jni | ||
$(GRADLE) build | ||
|
||
maven-bundle: apk | ||
jre-collect: jre-gradle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this one? |
||
mkdir -p build | ||
mv libdeepspeech_jre/libdeepspeech-jni.so build/ | ||
cp libdeepspeech_jre/libs/x86_64/libdeepspeech.so build/ | ||
cp libdeepspeech_jre/build/libs/libdeepspeech_jre.jar build/ | ||
|
||
jre-restore-makefile: | ||
mv Makefile.original Makefile | ||
|
||
maven-bundle: android | ||
$(GRADLE) uploadArchives | ||
$(GRADLE) zipMavenArtifacts | ||
|
||
bindings: clean ds-swig | ||
$(DS_SWIG_ENV) swig -c++ -java -package org.deepspeech.libdeepspeech -outdir libdeepspeech/src/main/java/org/deepspeech/libdeepspeech/ -o jni/deepspeech_wrap.cpp jni/deepspeech.i | ||
bindings: ds-swig | ||
mkdir -p ./tmp | ||
$(DS_SWIG_ENV) swig -c++ -java -package org.deepspeech.libdeepspeech -outdir ./tmp -o jni/deepspeech_wrap.cpp jni/deepspeech.i | ||
cp ./tmp/* libdeepspeech_android/src/main/java/org/deepspeech/libdeepspeech/ | ||
cp ./tmp/* libdeepspeech_jre/src/main/java/org/deepspeech/libdeepspeech/ | ||
rm -rf ./tmp |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
# Java bindings | ||
Full project description and documentation on GitHub: [https://github.com/mozilla/DeepSpeech](https://github.com/mozilla/DeepSpeech). | ||
|
||
## Android bindings | ||
For use with Android | ||
|
||
``make android`` | ||
|
||
>Note: The current example app in `./App` is not up to date with the latest changes to the bindings! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this ? |
||
|
||
## Standalone Java Bindings for DeepSpeech | ||
For use with standalone Java | ||
|
||
``make standalone`` | ||
|
||
### Usage information: | ||
See [standalone.md](standalone.md) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
buildscript { | ||
|
||
repositories { | ||
google() | ||
jcenter() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what we can do about that. Will need to check out which dependencies are from jcenter, I dont think we have any since the Android stuff is pulled from Google |
||
} | ||
dependencies { | ||
} | ||
} | ||
|
||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} | ||
|
||
dependencies { | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} | ||
|
||
ext { | ||
dsVersionString = rootProject.file('../../VERSION').text.trim() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we avoid updating |
||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
#!/usr/bin/env sh | ||
|
||
# | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same, avoid updating |
||
# Copyright 2015 the original author or authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
############################################################################## | ||
## | ||
## Gradle start up script for UN*X | ||
|
@@ -28,7 +44,7 @@ APP_NAME="Gradle" | |
APP_BASE_NAME=`basename "$0"` | ||
|
||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
DEFAULT_JVM_OPTS="" | ||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' | ||
|
||
# Use the maximum available, or set MAX_FD != -1 to use that value. | ||
MAX_FD="maximum" | ||
|
@@ -66,6 +82,7 @@ esac | |
|
||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | ||
|
||
|
||
# Determine the Java command to use to start the JVM. | ||
if [ -n "$JAVA_HOME" ] ; then | ||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
|
@@ -109,10 +126,11 @@ if $darwin; then | |
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" | ||
fi | ||
|
||
# For Cygwin, switch paths to Windows format before running java | ||
if $cygwin ; then | ||
# For Cygwin or MSYS, switch paths to Windows format before running java | ||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then | ||
APP_HOME=`cygpath --path --mixed "$APP_HOME"` | ||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | ||
|
||
JAVACMD=`cygpath --unix "$JAVACMD"` | ||
|
||
# We build the pattern for arguments to be converted via cygpath | ||
|
@@ -138,19 +156,19 @@ if $cygwin ; then | |
else | ||
eval `echo args$i`="\"$arg\"" | ||
fi | ||
i=$((i+1)) | ||
i=`expr $i + 1` | ||
done | ||
case $i in | ||
(0) set -- ;; | ||
(1) set -- "$args0" ;; | ||
(2) set -- "$args0" "$args1" ;; | ||
(3) set -- "$args0" "$args1" "$args2" ;; | ||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;; | ||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | ||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | ||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | ||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | ||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | ||
0) set -- ;; | ||
1) set -- "$args0" ;; | ||
2) set -- "$args0" "$args1" ;; | ||
3) set -- "$args0" "$args1" "$args2" ;; | ||
4) set -- "$args0" "$args1" "$args2" "$args3" ;; | ||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | ||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | ||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | ||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | ||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | ||
esac | ||
fi | ||
|
||
|
@@ -159,14 +177,9 @@ save () { | |
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done | ||
echo " " | ||
} | ||
APP_ARGS=$(save "$@") | ||
APP_ARGS=`save "$@"` | ||
|
||
# Collect all arguments for the java command, following the shell quoting and substitution rules | ||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" | ||
|
||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong | ||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then | ||
cd "$(dirname "$0")" | ||
fi | ||
|
||
exec "$JAVACMD" "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same