Skip to content

Commit

Permalink
added Recognizer.setGrammar(String) for java (#1229)
Browse files Browse the repository at this point in the history
  • Loading branch information
nalbion committed Dec 17, 2022
1 parent cf2560c commit 64d84b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions java/lib/src/main/java/org/vosk/LibVosk.java
Expand Up @@ -78,6 +78,8 @@ private static void unpackDll(File targetDir, String lib) throws IOException {

public static native String vosk_recognizer_partial_result(Pointer recognizer);

public static native void vosk_recognizer_set_grm(Pointer recognizer, String grammar);

public static native void vosk_recognizer_reset(Pointer recognizer);

public static native void vosk_recognizer_free(Pointer recognizer);
Expand Down
10 changes: 10 additions & 0 deletions java/lib/src/main/java/org/vosk/Recognizer.java
Expand Up @@ -60,6 +60,16 @@ public String getFinalResult() {
return LibVosk.vosk_recognizer_final_result(this.getPointer());
}

/**
* Reconfigures recognizer to use grammar.
*
* @param grammar Set of phrases in JSON array of strings or "[]" to use default model graph.
* @see #Recognizer(Model, float, String)
*/
public void setGrammar(String grammar) {
LibVosk.vosk_recognizer_set_grm(this.getPointer(), grammar);
}

public void reset() {
LibVosk.vosk_recognizer_reset(this.getPointer());
}
Expand Down

0 comments on commit 64d84b0

Please sign in to comment.