]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
bindings.java : apply whisperParams in fullTranscribeWithTime instead of ignoring...
authorJoas Dev <redacted>
Tue, 3 Jun 2025 04:15:21 +0000 (23:15 -0500)
committerGitHub <redacted>
Tue, 3 Jun 2025 04:15:21 +0000 (06:15 +0200)
This pull request fixes a bug in the fullTranscribeWithTime method, where the whisperParams argument was declared but never used. As a result, the model did not apply the configuration defined in whisperParams.

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

index 621d8c636ca886b426cbe8bbf1f9f5da99245b52..cc5314829c629a9dd9c4f1c6b14c08f331610d45 100644 (file)
@@ -168,23 +168,26 @@ public class WhisperCpp implements AutoCloseable {
         return str.toString().trim();\r
     }\r
 \r
-    public List<WhisperSegment> fullTranscribeWithTime(WhisperFullParams whisperParams, float[] audioData) throws IOException {\r
+    /**\r
+     * Full transcribe with time list.\r
+     *\r
+     * @param whisperParams the whisper params\r
+     * @param audioData     the audio data\r
+     * @return the list\r
+     * @throws IOException the io exception\r
+     */\r
+    public List<WhisperSegment> fullTranscribeWithTime(WhisperFullParams.ByValue whisperParams, float[] audioData) throws IOException {\r
         if (ctx == null) {\r
             throw new IllegalStateException("Model not initialised");\r
         }\r
 \r
-        WhisperFullParams.ByValue valueParams = new WhisperFullParams.ByValue(\r
-            lib.whisper_full_default_params_by_ref(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH.ordinal()));\r
-        valueParams.read();\r
-\r
-        if (lib.whisper_full(ctx, valueParams, audioData, audioData.length) != 0) {\r
+        if (lib.whisper_full(ctx, whisperParams, audioData, audioData.length) != 0) {\r
             throw new IOException("Failed to process audio");\r
         }\r
 \r
         int nSegments = lib.whisper_full_n_segments(ctx);\r
         List<WhisperSegment> segments= new ArrayList<>(nSegments);\r
 \r
-\r
         for (int i = 0; i < nSegments; i++) {\r
             long t0 = lib.whisper_full_get_segment_t0(ctx, i);\r
             String text = lib.whisper_full_get_segment_text(ctx, i);\r
index 9d63fff34e6ae5865167b85e3d87753879e4a1d5..bf37e5199922774b022e6f3164481292e14d3839 100644 (file)
@@ -118,7 +118,7 @@ class WhisperCppTest {
         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_BEAM_SEARCH);\r
+        WhisperFullParams.ByValue 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