Package io.github.givimad.whisperjni
Class WhisperGrammar
java.lang.Object
io.github.givimad.whisperjni.WhisperJNI.WhisperJNIPointer
io.github.givimad.whisperjni.WhisperGrammar
- All Implemented Interfaces:
AutoCloseable
The
WhisperGrammar class represents a native whisper.cpp parsed grammar.
You need to dispose the native memory for its instances by calling close()
- Author:
- Miguel Álvarez Díez - Initial contribution
-
Field Summary
Fields inherited from class io.github.givimad.whisperjni.WhisperJNI.WhisperJNIPointer
ref -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWhisperGrammar(WhisperJNI whisper, int ref, String text) Internal context constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertValidGrammar(String grammarText) Java implementation of a whisper.cpp grammar validator.static voidassertValidGrammar(Path grammar) Java implementation of a GBNF grammar validator.voidclose()Methods inherited from class io.github.givimad.whisperjni.WhisperJNI.WhisperJNIPointer
assertAvailable, isReleased, release
-
Constructor Details
-
WhisperGrammar
Internal context constructor- Parameters:
whisper- library instanceref- native pointer identifier
-
-
Method Details
-
close
public void close() -
assertValidGrammar
Java implementation of a GBNF grammar validator. Asserts the provided grammar is valid to use with whisper.cpp. Meaning it must contain a root expression with termination which sub-expressions can be resolved.- Parameters:
grammar- path to a GBNF grammar.- Throws:
ParseException- if grammar is invalid.IOException
-
assertValidGrammar
Java implementation of a whisper.cpp grammar validator. Asserts the provided grammar is valid to use with whisper.cpp. Meaning it must contain a root expression with termination which subexpressions can be resolved.- Parameters:
grammarText- GBNF grammar text.- Throws:
ParseException- if grammar is invalid.
-