Skip to content

Commit 269dad6

Browse files
authored
bindings.java : apply whisperParams in fullTranscribeWithTime instead of ignoring them (#3201)
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.
1 parent 121d27a commit 269dad6

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,23 +168,26 @@ public String fullTranscribe(WhisperFullParams.ByValue whisperParams, float[] au
168168
return str.toString().trim();
169169
}
170170

171-
public List<WhisperSegment> fullTranscribeWithTime(WhisperFullParams whisperParams, float[] audioData) throws IOException {
171+
/**
172+
* Full transcribe with time list.
173+
*
174+
* @param whisperParams the whisper params
175+
* @param audioData the audio data
176+
* @return the list
177+
* @throws IOException the io exception
178+
*/
179+
public List<WhisperSegment> fullTranscribeWithTime(WhisperFullParams.ByValue whisperParams, float[] audioData) throws IOException {
172180
if (ctx == null) {
173181
throw new IllegalStateException("Model not initialised");
174182
}
175183

176-
WhisperFullParams.ByValue valueParams = new WhisperFullParams.ByValue(
177-
lib.whisper_full_default_params_by_ref(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH.ordinal()));
178-
valueParams.read();
179-
180-
if (lib.whisper_full(ctx, valueParams, audioData, audioData.length) != 0) {
184+
if (lib.whisper_full(ctx, whisperParams, audioData, audioData.length) != 0) {
181185
throw new IOException("Failed to process audio");
182186
}
183187

184188
int nSegments = lib.whisper_full_n_segments(ctx);
185189
List<WhisperSegment> segments= new ArrayList<>(nSegments);
186190

187-
188191
for (int i = 0; i < nSegments; i++) {
189192
long t0 = lib.whisper_full_get_segment_t0(ctx, i);
190193
String text = lib.whisper_full_get_segment_text(ctx, i);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void testFullTranscribeWithTime() throws Exception {
118118
float[] floats = new float[b.length / 2];
119119

120120
//WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY);
121-
WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH);
121+
WhisperFullParams.ByValue params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH);
122122
params.setProgressCallback((ctx, state, progress, user_data) -> System.out.println("progress: " + progress));
123123
params.print_progress = CBool.FALSE;
124124
//params.initial_prompt = "and so my fellow Americans um, like";

0 commit comments

Comments
 (0)