diff --git a/bindings/java/src/main/java/io/github/ggerganov/whispercpp/params/WhisperFullParams.java b/bindings/java/src/main/java/io/github/ggerganov/whispercpp/params/WhisperFullParams.java index 7765561e..43c9a0dc 100644 --- a/bindings/java/src/main/java/io/github/ggerganov/whispercpp/params/WhisperFullParams.java +++ b/bindings/java/src/main/java/io/github/ggerganov/whispercpp/params/WhisperFullParams.java @@ -58,6 +58,9 @@ public class WhisperFullParams extends Structure { no_context = enable ? CBool.FALSE : CBool.TRUE; } + /** Generate timestamps or not? */ + public CBool no_timestamps; + /** Flag to force single segment output (useful for streaming). (default = false) */ public CBool single_segment; @@ -304,10 +307,16 @@ public class WhisperFullParams extends Structure { logits_filter_callback = CallbackReference.getFunctionPointer(callback); } + /** Grammar stuff */ + public Pointer grammar_rules; + public long n_grammar_rules; + public long i_start_rule; + public float grammar_penalty; + @Override protected List getFieldOrder() { return Arrays.asList("strategy", "n_threads", "n_max_text_ctx", "offset_ms", "duration_ms", "translate", - "no_context", "single_segment", + "no_context", "single_segment", "no_timestamps", "print_special", "print_progress", "print_realtime", "print_timestamps", "token_timestamps", "thold_pt", "thold_ptsum", "max_len", "split_on_word", "max_tokens", "speed_up", "audio_ctx", "tdrz_enable", "initial_prompt", "prompt_tokens", "prompt_n_tokens", "language", "detect_language", @@ -316,6 +325,7 @@ public class WhisperFullParams extends Structure { "new_segment_callback", "new_segment_callback_user_data", "progress_callback", "progress_callback_user_data", "encoder_begin_callback", "encoder_begin_callback_user_data", - "logits_filter_callback", "logits_filter_callback_user_data"); + "logits_filter_callback", "logits_filter_callback_user_data", + "grammar_rules", "n_grammar_rules", "i_start_rule", "grammar_penalty"); } } diff --git a/bindings/java/src/test/java/io/github/ggerganov/whispercpp/WhisperCppTest.java b/bindings/java/src/test/java/io/github/ggerganov/whispercpp/WhisperCppTest.java index ccc3be89..2973243d 100644 --- a/bindings/java/src/test/java/io/github/ggerganov/whispercpp/WhisperCppTest.java +++ b/bindings/java/src/test/java/io/github/ggerganov/whispercpp/WhisperCppTest.java @@ -22,12 +22,12 @@ class WhisperCppTest { static void init() throws FileNotFoundException { // By default, models are loaded from ~/.cache/whisper/ and are usually named "ggml-${name}.bin" // or you can provide the absolute path to the model file. - String modelName = "../../models/ggml-tiny.bin"; -// String modelName = "../../models/ggml-tiny.en.bin"; + //String modelName = "../../models/ggml-tiny.bin"; + String modelName = "../../models/ggml-tiny.en.bin"; try { whisper.initContext(modelName); -// whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY); -// whisper.getJavaDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH); + //whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY); + //whisper.getJavaDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH); modelInitialised = true; } catch (FileNotFoundException ex) { System.out.println("Model " + modelName + " not found"); @@ -75,11 +75,11 @@ class WhisperCppTest { byte[] b = new byte[audioInputStream.available()]; float[] floats = new float[b.length / 2]; -// WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY); + //WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY); WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH); params.setProgressCallback((ctx, state, progress, user_data) -> System.out.println("progress: " + progress)); params.print_progress = CBool.FALSE; -// params.initial_prompt = "and so my fellow Americans um, like"; + //params.initial_prompt = "and so my fellow Americans um, like"; try { @@ -117,12 +117,11 @@ class WhisperCppTest { byte[] b = new byte[audioInputStream.available()]; float[] floats = new float[b.length / 2]; -// WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY); + //WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY); WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH); params.setProgressCallback((ctx, state, progress, user_data) -> System.out.println("progress: " + progress)); params.print_progress = CBool.FALSE; -// params.initial_prompt = "and so my fellow Americans um, like"; - + //params.initial_prompt = "and so my fellow Americans um, like"; try { audioInputStream.read(b);