diff --git a/doc/BUILDING.rst b/doc/BUILDING.rst index 3c20cb29..16c5734a 100644 --- a/doc/BUILDING.rst +++ b/doc/BUILDING.rst @@ -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`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/Java-API.rst b/doc/Java-API.rst index 2986ca97..e0c6a7dd 100644 --- a/doc/Java-API.rst +++ b/doc/Java-API.rst @@ -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 diff --git a/native_client/java/jni/deepspeech.i b/native_client/java/jni/deepspeech.i index c028714c..cd5a97a5 100644 --- a/native_client/java/jni/deepspeech.i +++ b/native_client/java/jni/deepspeech.i @@ -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" diff --git a/native_client/java/libdeepspeech/src/androidTest/java/org/mozilla/deepspeech/libdeepspeech/test/BasicTest.java b/native_client/java/libdeepspeech/src/androidTest/java/org/mozilla/deepspeech/libdeepspeech/test/BasicTest.java index f7eccf00..08fce905 100644 --- a/native_client/java/libdeepspeech/src/androidTest/java/org/mozilla/deepspeech/libdeepspeech/test/BasicTest.java +++ b/native_client/java/libdeepspeech/src/androidTest/java/org/mozilla/deepspeech/libdeepspeech/test/BasicTest.java @@ -63,7 +63,7 @@ public class BasicTest { 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; diff --git a/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/CandidateTranscript.java b/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/CandidateTranscript.java index fa13c474..72dc0f1f 100644 --- a/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/CandidateTranscript.java +++ b/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/CandidateTranscript.java @@ -35,19 +35,11 @@ public class CandidateTranscript { } } - /** - * 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); } /** @@ -56,7 +48,7 @@ public class CandidateTranscript { * contributed to the creation of this transcript. */ public double getConfidence() { - return implJNI.CandidateTranscript_confidence_get(swigCPtr, this); + return implJNI.CandidateTranscript_Confidence_get(swigCPtr, this); } /** diff --git a/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/DeepSpeech_Error_Codes.java b/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/DeepSpeech_Error_Codes.java index ed47183e..f93f3e8c 100644 --- a/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/DeepSpeech_Error_Codes.java +++ b/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/DeepSpeech_Error_Codes.java @@ -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), diff --git a/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/Metadata.java b/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/Metadata.java index d2831bc4..9ef25e1e 100644 --- a/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/Metadata.java +++ b/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/Metadata.java @@ -39,19 +39,11 @@ public class Metadata { } } - /** - * 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); } /** diff --git a/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/MetadataItem.java b/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/MetadataItem.java deleted file mode 100644 index 9322f23a..00000000 --- a/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/MetadataItem.java +++ /dev/null @@ -1,79 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package org.mozilla.deepspeech.libdeepspeech; - -/** - * Stores each individual character, along with its timing information - */ -public class MetadataItem { - private transient long swigCPtr; - protected transient boolean swigCMemOwn; - - protected MetadataItem(long cPtr, boolean cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr(MetadataItem obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } - - public synchronized void delete() { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - throw new UnsupportedOperationException("C++ destructor does not have public access"); - } - swigCPtr = 0; - } - } - - /** - * The character generated for transcription - */ - public void setCharacter(String value) { - implJNI.MetadataItem_character_set(swigCPtr, this, value); - } - - /** - * The character generated for transcription - */ - public String getCharacter() { - return implJNI.MetadataItem_character_get(swigCPtr, this); - } - - /** - * Position of the character in units of 20ms - */ - public void setTimestep(int value) { - implJNI.MetadataItem_timestep_set(swigCPtr, this, value); - } - - /** - * Position of the character in units of 20ms - */ - public int getTimestep() { - return implJNI.MetadataItem_timestep_get(swigCPtr, this); - } - - /** - * Position of the character in seconds - */ - public void setStart_time(float value) { - implJNI.MetadataItem_start_time_set(swigCPtr, this, value); - } - - /** - * Position of the character in seconds - */ - public float getStart_time() { - return implJNI.MetadataItem_start_time_get(swigCPtr, this); - } - -} diff --git a/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/TokenMetadata.java b/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/TokenMetadata.java index d14fc161..6f976f21 100644 --- a/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/TokenMetadata.java +++ b/native_client/java/libdeepspeech/src/main/java/org/mozilla/deepspeech/libdeepspeech_doc/TokenMetadata.java @@ -38,21 +38,21 @@ public class TokenMetadata { * 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); } }