]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
java : use tiny.en for tests (#1484)
authorGeorgi Gerganov <redacted>
Mon, 13 Nov 2023 14:53:55 +0000 (16:53 +0200)
committerGitHub <redacted>
Mon, 13 Nov 2023 14:53:55 +0000 (16:53 +0200)
* java : use tiny.en for tests

* java : try to fix full params struct

bindings/java/src/main/java/io/github/ggerganov/whispercpp/params/WhisperFullParams.java
bindings/java/src/test/java/io/github/ggerganov/whispercpp/WhisperCppTest.java

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