Skip to content
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

Fix some style inconsistencies in Java bindings (Fixes #3121) #3135

Merged
merged 3 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/BUILDING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ You can build the ``libdeepspeech.so`` using (ARMv7):

.. code-block::

bazel build --workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" --config=monolithic --config=android --config=android_arm --define=runtime=tflite --action_env ANDROID_NDK_API_LEVEL=21 --cxxopt=-std=c++11 --copt=-D_GLIBCXX_USE_C99 //native_client:libdeepspeech.so
bazel build --workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" --config=monolithic --config=android --config=android_arm --define=runtime=tflite --action_env ANDROID_NDK_API_LEVEL=21 --cxxopt=-std=c++14 --copt=-D_GLIBCXX_USE_C99 //native_client:libdeepspeech.so

Or (ARM64):

.. code-block::

bazel build --workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" --config=monolithic --config=android --config=android_arm64 --define=runtime=tflite --action_env ANDROID_NDK_API_LEVEL=21 --cxxopt=-std=c++11 --copt=-D_GLIBCXX_USE_C99 //native_client:libdeepspeech.so
bazel build --workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" --config=monolithic --config=android --config=android_arm64 --define=runtime=tflite --action_env ANDROID_NDK_API_LEVEL=21 --cxxopt=-std=c++14 --copt=-D_GLIBCXX_USE_C99 //native_client:libdeepspeech.so

Building ``libdeepspeech.aar``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
6 changes: 3 additions & 3 deletions doc/Java-API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ Metadata

.. doxygenclass:: org::mozilla::deepspeech::libdeepspeech::Metadata
:project: deepspeech-java
:members: getTranscripts, getNum_transcripts, getTranscript
:members: getNumTranscripts, getTranscript

CandidateTranscript
-------------------

.. doxygenclass:: org::mozilla::deepspeech::libdeepspeech::CandidateTranscript
:project: deepspeech-java
:members: getTokens, getNum_tokens, getConfidence, getToken
:members: getNumTokens, getConfidence, getToken

TokenMetadata
-------------
.. doxygenclass:: org::mozilla::deepspeech::libdeepspeech::TokenMetadata
:project: deepspeech-java
:members: getText, getTimestep, getStart_time
:members: getText, getTimestep, getStartTime
9 changes: 9 additions & 0 deletions native_client/java/jni/deepspeech.i
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,13 @@

%rename ("%(strip:[DS_])s") "";

// make struct members camel case to suit Java conventions
%rename ("%(camelcase)s", %$ismember) "";

// ignore automatically generated getTokens and getTranscripts since they don't
// do anything useful and we have already provided getToken(int i) and
// getTranscript(int i) above.
%ignore "Metadata::transcripts";
%ignore "CandidateTranscript::tokens";

%include "../deepspeech.h"
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void loadDeepSpeech_basic() {

private String candidateTranscriptToString(CandidateTranscript t) {
String retval = "";
for (int i = 0; i < t.getNum_tokens(); ++i) {
for (int i = 0; i < t.getNumTokens(); ++i) {
retval += t.getToken(i).getText();
}
return retval;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,11 @@ public synchronized void delete() {
}
}

/**
* Array of TokenMetadata objects
*/
public TokenMetadata getTokens() {
long cPtr = implJNI.CandidateTranscript_tokens_get(swigCPtr, this);
return (cPtr == 0) ? null : new TokenMetadata(cPtr, false);
}

/**
* Size of the tokens array
*/
public long getNum_tokens() {
return implJNI.CandidateTranscript_num_tokens_get(swigCPtr, this);
public long getNumTokens() {
return implJNI.CandidateTranscript_NumTokens_get(swigCPtr, this);
}

/**
Expand All @@ -56,7 +48,7 @@ public long getNum_tokens() {
* contributed to the creation of this transcript.
*/
public double getConfidence() {
return implJNI.CandidateTranscript_confidence_get(swigCPtr, this);
return implJNI.CandidateTranscript_Confidence_get(swigCPtr, this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public enum DeepSpeech_Error_Codes {
ERR_INVALID_SCORER(0x2002),
ERR_MODEL_INCOMPATIBLE(0x2003),
ERR_SCORER_NOT_ENABLED(0x2004),
ERR_SCORER_UNREADABLE(0x2005),
ERR_SCORER_INVALID_LM(0x2006),
ERR_SCORER_NO_TRIE(0x2007),
ERR_SCORER_INVALID_TRIE(0x2008),
ERR_SCORER_VERSION_MISMATCH(0x2009),
ERR_FAIL_INIT_MMAP(0x3000),
ERR_FAIL_INIT_SESS(0x3001),
ERR_FAIL_INTERPRETER(0x3002),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,11 @@ public synchronized void delete() {
}
}

/**
* Array of CandidateTranscript objects
*/
public CandidateTranscript getTranscripts() {
long cPtr = implJNI.Metadata_transcripts_get(swigCPtr, this);
return (cPtr == 0) ? null : new CandidateTranscript(cPtr, false);
}

/**
* Size of the transcripts array
*/
public long getNum_transcripts() {
return implJNI.Metadata_num_transcripts_get(swigCPtr, this);
public long getNumTranscripts() {
return implJNI.Metadata_NumTranscripts_get(swigCPtr, this);
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ public synchronized void delete() {
* The text corresponding to this token
*/
public String getText() {
return implJNI.TokenMetadata_text_get(swigCPtr, this);
return implJNI.TokenMetadata_Text_get(swigCPtr, this);
}

/**
* Position of the token in units of 20ms
*/
public long getTimestep() {
return implJNI.TokenMetadata_timestep_get(swigCPtr, this);
return implJNI.TokenMetadata_Timestep_get(swigCPtr, this);
}

/**
* Position of the token in seconds
*/
public float getStart_time() {
return implJNI.TokenMetadata_start_time_get(swigCPtr, this);
public float getStartTime() {
return implJNI.TokenMetadata_StartTime_get(swigCPtr, this);
}

}