java : use tiny.en for tests (#1484)

* java : use tiny.en for tests

* java : try to fix full params struct
This commit is contained in:
Georgi Gerganov 2023-11-13 16:53:55 +02:00 committed by GitHub
parent 3e5c7feeff
commit d4231649e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 11 deletions

View File

@ -58,6 +58,9 @@ public class WhisperFullParams extends Structure {
no_context = enable ? CBool.FALSE : CBool.TRUE; 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) */ /** Flag to force single segment output (useful for streaming). (default = false) */
public CBool single_segment; public CBool single_segment;
@ -304,10 +307,16 @@ public class WhisperFullParams extends Structure {
logits_filter_callback = CallbackReference.getFunctionPointer(callback); 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 @Override
protected List<String> getFieldOrder() { protected List<String> getFieldOrder() {
return Arrays.asList("strategy", "n_threads", "n_max_text_ctx", "offset_ms", "duration_ms", "translate", 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", "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", "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", "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", "new_segment_callback", "new_segment_callback_user_data",
"progress_callback", "progress_callback_user_data", "progress_callback", "progress_callback_user_data",
"encoder_begin_callback", "encoder_begin_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");
} }
} }

View File

@ -22,8 +22,8 @@ class WhisperCppTest {
static void init() throws FileNotFoundException { static void init() throws FileNotFoundException {
// By default, models are loaded from ~/.cache/whisper/ and are usually named "ggml-${name}.bin" // 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. // or you can provide the absolute path to the model file.
String modelName = "../../models/ggml-tiny.bin"; //String modelName = "../../models/ggml-tiny.bin";
// String modelName = "../../models/ggml-tiny.en.bin"; String modelName = "../../models/ggml-tiny.en.bin";
try { try {
whisper.initContext(modelName); whisper.initContext(modelName);
//whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY); //whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY);
@ -123,7 +123,6 @@ class WhisperCppTest {
params.print_progress = CBool.FALSE; 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 { try {
audioInputStream.read(b); audioInputStream.read(b);