Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit 07ba928

Browse files
author
TheDutchMC
committed
Conversion to Makefile
- Replaced setup.sh with target `standalone` in Makefile - Updated documentation accordingly - Updated CMakeLists_standalone to work with it now being used from Make (some path things for libdeepspeech.so) - Fixed some wrongly formatted javadoc in DeepSpeechModel.java
1 parent a15aed6 commit 07ba928

File tree

7 files changed

+82
-169
lines changed

7 files changed

+82
-169
lines changed

native_client/java/.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#User input
2-
libdeepspeech/libs/*.so
1+
#Native libs
2+
libdeepspeech/libs/*
3+
libdeepspeech/*.so
34

45
#Gradle
56
.gradle/
@@ -11,7 +12,6 @@ libdeepspeech/CMakeFiles/
1112
libdeepspeech/cmake_install.cmake
1213
libdeepspeech/CMakeCache.txt
1314
libdeepspeech/Makefile
14-
libdeepspeech/libdeepspeech-jni.so
1515

1616
#SWIG
1717
jni/*.cpp

native_client/java/Makefile

Lines changed: 71 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,71 @@
1-
.PHONY: clean apk-clean
2-
3-
include ../definitions.mk
4-
5-
ARCHS := $(shell grep 'ABI_FILTERS' libdeepspeech/gradle.properties | cut -d'=' -f2 | sed -e 's/;/ /g')
6-
GRADLE ?= ./gradlew
7-
8-
all: apk
9-
10-
clean: apk-clean
11-
rm -rf *.java jni/deepspeech_wrap.cpp
12-
13-
apk-clean:
14-
$(GRADLE) clean
15-
16-
libs-clean:
17-
rm -fr libdeepspeech/libs/*/libdeepspeech.so
18-
19-
libdeepspeech/libs/%/libdeepspeech.so:
20-
-mkdir libdeepspeech/libs/$*/
21-
cp ${TFDIR}/bazel-out/$*-*/bin/native_client/libdeepspeech.so libdeepspeech/libs/$*/
22-
23-
apk: apk-clean bindings $(patsubst %,libdeepspeech/libs/%/libdeepspeech.so,$(ARCHS))
24-
$(GRADLE) build
25-
26-
maven-bundle: apk
27-
$(GRADLE) uploadArchives
28-
$(GRADLE) zipMavenArtifacts
29-
30-
bindings: clean ds-swig
31-
$(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
1+
.PHONY: clean apk-clean jre jre-prepare jre-libdeepspeech-jni jre-gradle jre-collect jre-clean apk-prepare
2+
3+
include ../definitions.mk
4+
5+
ARCHS := $(shell grep 'ABI_FILTERS' libdeepspeech/gradle.properties | cut -d'=' -f2 | sed -e 's/;/ /g')
6+
GRADLE ?= ./gradlew
7+
8+
all: apk jre
9+
android: apk
10+
standalone: jre
11+
12+
clean: apk-clean jre-clean
13+
rm -rf *.java jni/deepspeech_wrap.cpp
14+
15+
apk-clean:
16+
$(GRADLE) clean
17+
18+
libs-clean:
19+
rm -fr libdeepspeech/libs/*/libdeepspeech.so
20+
21+
libdeepspeech/libs/%/libdeepspeech.so:
22+
-mkdir libdeepspeech/libs/$*/
23+
cp ${TFDIR}/bazel-out/$*-*/bin/native_client/libdeepspeech.so libdeepspeech/libs/$*/
24+
25+
apk-prepare:
26+
cp build.gradle.android build.gradle
27+
cp libdeepspeech/build.gradle.android libdeepspeech/build.gradle
28+
cp libdeepspeech/CMakeLists_android.txt libdeepspeech/CMakeLists.txt
29+
30+
apk: apk-prepare apk-clean bindings $(patsubst %,libdeepspeech/libs/%/libdeepspeech.so,$(ARCHS))
31+
$(GRADLE) build
32+
33+
jre: jre-prepare jre-collect jre-restore-makefile jre-clean
34+
jre-prepare: $(patsubst %,libdeepspeech/libs/%/libdeepspeech.so,$(ARCHS))
35+
cp Makefile Makefile.original
36+
cp build.gradle.standalone build.gradle
37+
cp libdeepspeech/build.gradle.standalone libdeepspeech/build.gradle
38+
cp libdeepspeech/CMakeLists_standalone.txt libdeepspeech/CMakeLists.txt
39+
sed -i 's|__JAVA_HOME__|'${JAVA_HOME}'|g' libdeepspeech/CMakeLists.txt
40+
41+
jre-libdeepspeech-jni: bindings
42+
cd libdeepspeech; \
43+
cmake .; \
44+
$(MAKE)
45+
46+
jre-gradle: jre-libdeepspeech-jni
47+
$(GRADLE) build
48+
49+
jre-collect: jre-gradle
50+
mkdir -p build
51+
mv libdeepspeech/libdeepspeech-jni.so build/
52+
cp libdeepspeech/libs/x86_64/libdeepspeech.so build/
53+
cp libdeepspeech/build/libs/libdeepspeech.jar build/
54+
55+
jre-clean:
56+
rm -f libdeepspeech/CMakeLists.txt
57+
rm -f libdeepspeech/build.gradle
58+
rm -f build.gradle
59+
rm -f jni/deepspeech_wrap.cpp jni/deepspeech_wrap.o
60+
rm -rf libdeepspeech/cmake_install.cmake libdeepspeech/CMakeCache.txt libdeepspeech/Makefile libdeepspeech/CMakeFiles/
61+
rm -rf libdeepspeech/build/
62+
63+
jre-restore-makefile:
64+
mv Makefile.original Makefile
65+
66+
maven-bundle: apk
67+
$(GRADLE) uploadArchives
68+
$(GRADLE) zipMavenArtifacts
69+
70+
bindings: clean ds-swig
71+
$(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

native_client/java/README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@ Full project description and documentation on GitHub: [https://github.com/mozill
44
## Android bindings
55
For use with Android
66

7-
### Preparation
8-
1. Rename `./build.gradle.android` to `build.gradle`
9-
2. Rename `./libdeepspeech/build.gradle.android` to `build.gradle`
10-
3. Rename `./libdeepspeech/CMakeLists_android.txt` to `CMakeLists.txt`
11-
12-
### Build
13-
1. In `./` run `make`
7+
``make android``
148

159
>Note: The current example app in `./App` is not up to date with the latest changes to the bindings!
1610
1711
## Standalone Java Bindings for DeepSpeech
1812
For use with standalone Java
1913

14+
``make standalone``
15+
16+
### Usage information:
2017
See [standalone.md](standalone.md)

native_client/java/libdeepspeech/CMakeLists_standalone.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ include_directories( ${CMAKE_JAVA_} __JAVA_HOME__/include __JAVA_HOME__/include/
1212

1313
add_library( deepspeech-jni SHARED ../jni/deepspeech_wrap.cpp )
1414

15-
find_library(deepspeech-lib NAMES deepspeech PATHS ${CMAKE_SOURCE_DIR}/libs/ REQUIRED)
15+
find_library(deepspeech-lib NAMES deepspeech PATHS ${CMAKE_SOURCE_DIR}/libs/x86_64/ REQUIRED)
1616
message(STATUS ${deepspeech-lib})
1717

18-
add_custom_command( TARGET deepspeech-jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/libs/libdeepspeech.so $ENV{CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libdeepspeech.so )
18+
add_custom_command( TARGET deepspeech-jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/libs/x86_64/libdeepspeech.so ${CMAKE_SOURCE_DIR}/libdeepspeech.so )
1919

2020
target_link_libraries( deepspeech-jni ${deepspeech-lib} )

native_client/java/libdeepspeech/src/main/java/org/deepspeech/libdeepspeech/DeepSpeechModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void setScorerAlphaBeta(float alpha, float beta) {
128128
evaluateErrorCode(impl.SetScorerAlphaBeta(this._msp, alpha, beta));
129129
}
130130

131-
/*
131+
/**
132132
* @brief Use the DeepSpeech model to perform Speech-To-Text.
133133
*
134134
* @param buffer A 16-bit, mono raw audio signal at the appropriate

native_client/java/setup.sh

Lines changed: 0 additions & 121 deletions
This file was deleted.

native_client/java/standalone.md

100644100755
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
### Setup
2-
1. Get `libdeepspeech.so` by compiling or (from here)[], and copy it into `./libdeepspeech/libs/`
3-
2. Run `setup.sh` as root or with `sudo`
4-
3. You can now find the files needed for your project at `./build/`
1+
# DeepSpeech for standalone Java
52

63
### Adding DeepSpeech to your Java project
74
>Note: You can do this on your own way too, but this works with the example usage code provided below.

0 commit comments

Comments
 (0)