Refactoring for readability

This commit is contained in:
Andreas Lubbe 2025-09-09 08:59:26 +02:00
parent 02714dddde
commit e7468c2949
2 changed files with 7 additions and 3 deletions

View File

@ -333,7 +333,7 @@ public class WhisperFullParams extends Structure {
@Override
protected List<String> getFieldOrder() {
return Arrays.asList("strategy", "n_threads", "n_max_text_ctx",
return Arrays.asList("strategy", "n_threads", "n_max_text_ctx",
"offset_ms", "duration_ms", "translate", "no_context",
"no_timestamps", "single_segment", "print_special",
"print_progress", "print_realtime", "print_timestamps",

View File

@ -7093,8 +7093,12 @@ int whisper_full_with_state(
prompt.clear();
// if we have already generated some text, use it as a prompt to condition the next generation
if (( (!prompt_past.empty()) || (params.carry_initial_prompt && !initial_prompt_tokens.empty() && !first_iter_with_prompt) )
&& t_cur < 0.5f && params.n_max_text_ctx > 0) {
const bool has_past_text = !prompt_past.empty();
const bool carrying_initial_prompt_now = params.carry_initial_prompt && !initial_prompt_tokens.empty() && !first_iter_with_prompt;
// We only condition on previous text at lower temperatures and when a context limit is set
const bool allow_conditioning = (t_cur < 0.5f) && (params.n_max_text_ctx > 0);
if ((has_past_text || carrying_initial_prompt_now) && allow_conditioning) {
int max_ctx_half = std::min(params.n_max_text_ctx, whisper_n_text_ctx(ctx)/2);
prompt = { whisper_token_prev(ctx) };
if (params.carry_initial_prompt) {