Spaces:
Sleeping
Sleeping
java : use tiny.en for tests (#1484)
Browse files* 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
CHANGED
|
@@ -58,6 +58,9 @@ public class WhisperFullParams extends Structure {
|
|
| 58 |
no_context = enable ? CBool.FALSE : CBool.TRUE;
|
| 59 |
}
|
| 60 |
|
|
|
|
|
|
|
|
|
|
| 61 |
/** Flag to force single segment output (useful for streaming). (default = false) */
|
| 62 |
public CBool single_segment;
|
| 63 |
|
|
@@ -304,10 +307,16 @@ public class WhisperFullParams extends Structure {
|
|
| 304 |
logits_filter_callback = CallbackReference.getFunctionPointer(callback);
|
| 305 |
}
|
| 306 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
@Override
|
| 308 |
protected List<String> getFieldOrder() {
|
| 309 |
return Arrays.asList("strategy", "n_threads", "n_max_text_ctx", "offset_ms", "duration_ms", "translate",
|
| 310 |
-
"no_context", "single_segment",
|
| 311 |
"print_special", "print_progress", "print_realtime", "print_timestamps", "token_timestamps",
|
| 312 |
"thold_pt", "thold_ptsum", "max_len", "split_on_word", "max_tokens", "speed_up", "audio_ctx",
|
| 313 |
"tdrz_enable", "initial_prompt", "prompt_tokens", "prompt_n_tokens", "language", "detect_language",
|
|
@@ -316,6 +325,7 @@ public class WhisperFullParams extends Structure {
|
|
| 316 |
"new_segment_callback", "new_segment_callback_user_data",
|
| 317 |
"progress_callback", "progress_callback_user_data",
|
| 318 |
"encoder_begin_callback", "encoder_begin_callback_user_data",
|
| 319 |
-
"logits_filter_callback", "logits_filter_callback_user_data"
|
|
|
|
| 320 |
}
|
| 321 |
}
|
|
|
|
| 58 |
no_context = enable ? CBool.FALSE : CBool.TRUE;
|
| 59 |
}
|
| 60 |
|
| 61 |
+
/** Generate timestamps or not? */
|
| 62 |
+
public CBool no_timestamps;
|
| 63 |
+
|
| 64 |
/** Flag to force single segment output (useful for streaming). (default = false) */
|
| 65 |
public CBool single_segment;
|
| 66 |
|
|
|
|
| 307 |
logits_filter_callback = CallbackReference.getFunctionPointer(callback);
|
| 308 |
}
|
| 309 |
|
| 310 |
+
/** Grammar stuff */
|
| 311 |
+
public Pointer grammar_rules;
|
| 312 |
+
public long n_grammar_rules;
|
| 313 |
+
public long i_start_rule;
|
| 314 |
+
public float grammar_penalty;
|
| 315 |
+
|
| 316 |
@Override
|
| 317 |
protected List<String> getFieldOrder() {
|
| 318 |
return Arrays.asList("strategy", "n_threads", "n_max_text_ctx", "offset_ms", "duration_ms", "translate",
|
| 319 |
+
"no_context", "single_segment", "no_timestamps",
|
| 320 |
"print_special", "print_progress", "print_realtime", "print_timestamps", "token_timestamps",
|
| 321 |
"thold_pt", "thold_ptsum", "max_len", "split_on_word", "max_tokens", "speed_up", "audio_ctx",
|
| 322 |
"tdrz_enable", "initial_prompt", "prompt_tokens", "prompt_n_tokens", "language", "detect_language",
|
|
|
|
| 325 |
"new_segment_callback", "new_segment_callback_user_data",
|
| 326 |
"progress_callback", "progress_callback_user_data",
|
| 327 |
"encoder_begin_callback", "encoder_begin_callback_user_data",
|
| 328 |
+
"logits_filter_callback", "logits_filter_callback_user_data",
|
| 329 |
+
"grammar_rules", "n_grammar_rules", "i_start_rule", "grammar_penalty");
|
| 330 |
}
|
| 331 |
}
|
bindings/java/src/test/java/io/github/ggerganov/whispercpp/WhisperCppTest.java
CHANGED
|
@@ -22,12 +22,12 @@ class WhisperCppTest {
|
|
| 22 |
static void init() throws FileNotFoundException {
|
| 23 |
// By default, models are loaded from ~/.cache/whisper/ and are usually named "ggml-${name}.bin"
|
| 24 |
// or you can provide the absolute path to the model file.
|
| 25 |
-
String modelName = "../../models/ggml-tiny.bin";
|
| 26 |
-
|
| 27 |
try {
|
| 28 |
whisper.initContext(modelName);
|
| 29 |
-
//
|
| 30 |
-
//
|
| 31 |
modelInitialised = true;
|
| 32 |
} catch (FileNotFoundException ex) {
|
| 33 |
System.out.println("Model " + modelName + " not found");
|
|
@@ -75,11 +75,11 @@ class WhisperCppTest {
|
|
| 75 |
byte[] b = new byte[audioInputStream.available()];
|
| 76 |
float[] floats = new float[b.length / 2];
|
| 77 |
|
| 78 |
-
//
|
| 79 |
WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH);
|
| 80 |
params.setProgressCallback((ctx, state, progress, user_data) -> System.out.println("progress: " + progress));
|
| 81 |
params.print_progress = CBool.FALSE;
|
| 82 |
-
//
|
| 83 |
|
| 84 |
|
| 85 |
try {
|
|
@@ -117,12 +117,11 @@ class WhisperCppTest {
|
|
| 117 |
byte[] b = new byte[audioInputStream.available()];
|
| 118 |
float[] floats = new float[b.length / 2];
|
| 119 |
|
| 120 |
-
//
|
| 121 |
WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH);
|
| 122 |
params.setProgressCallback((ctx, state, progress, user_data) -> System.out.println("progress: " + progress));
|
| 123 |
params.print_progress = CBool.FALSE;
|
| 124 |
-
//
|
| 125 |
-
|
| 126 |
|
| 127 |
try {
|
| 128 |
audioInputStream.read(b);
|
|
|
|
| 22 |
static void init() throws FileNotFoundException {
|
| 23 |
// By default, models are loaded from ~/.cache/whisper/ and are usually named "ggml-${name}.bin"
|
| 24 |
// or you can provide the absolute path to the model file.
|
| 25 |
+
//String modelName = "../../models/ggml-tiny.bin";
|
| 26 |
+
String modelName = "../../models/ggml-tiny.en.bin";
|
| 27 |
try {
|
| 28 |
whisper.initContext(modelName);
|
| 29 |
+
//whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY);
|
| 30 |
+
//whisper.getJavaDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH);
|
| 31 |
modelInitialised = true;
|
| 32 |
} catch (FileNotFoundException ex) {
|
| 33 |
System.out.println("Model " + modelName + " not found");
|
|
|
|
| 75 |
byte[] b = new byte[audioInputStream.available()];
|
| 76 |
float[] floats = new float[b.length / 2];
|
| 77 |
|
| 78 |
+
//WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY);
|
| 79 |
WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH);
|
| 80 |
params.setProgressCallback((ctx, state, progress, user_data) -> System.out.println("progress: " + progress));
|
| 81 |
params.print_progress = CBool.FALSE;
|
| 82 |
+
//params.initial_prompt = "and so my fellow Americans um, like";
|
| 83 |
|
| 84 |
|
| 85 |
try {
|
|
|
|
| 117 |
byte[] b = new byte[audioInputStream.available()];
|
| 118 |
float[] floats = new float[b.length / 2];
|
| 119 |
|
| 120 |
+
//WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY);
|
| 121 |
WhisperFullParams params = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_BEAM_SEARCH);
|
| 122 |
params.setProgressCallback((ctx, state, progress, user_data) -> System.out.println("progress: " + progress));
|
| 123 |
params.print_progress = CBool.FALSE;
|
| 124 |
+
//params.initial_prompt = "and so my fellow Americans um, like";
|
|
|
|
| 125 |
|
| 126 |
try {
|
| 127 |
audioInputStream.read(b);
|