Skip to content

Wrap mid-decode callbacks (progress, new_segment, filter_logits, start_encoder) #15

@uqio

Description

@uqio

Tracked under #6.

Scope

Each callback type requires the same trampoline discipline as the existing abort-callback wiring (Box<dyn FnMut> on Params, C-typed trampoline, lifetime story tied to the Params). Wrapping them unlocks streaming partial-result emission and progress UIs.

Symbols

  • set_progress_callback* — periodic progress (0.0–1.0).
  • set_new_segment_callback* — fires when a new decoded segment is ready (the underlying mechanism for streaming partial results).
  • set_filter_logits_callback* — pre-sampling logits filter (advanced).
  • set_start_encoder_callback* — fires before each encoder invocation.

Why deferred

Whispery's chunk-at-a-time pump emits results at end-of-chunk, not mid-decode. Each callback duplicates the abort-callback pattern; the cost is per-callback, not amortised.

Why this matters more than it looks

The new_segment_callback is the underlying mechanism for streaming partial-result emission — see #4 (async-friendly State::full) and #3 (iterator-based output API). For true mid-decode streaming this callback would need wrapping; the iterator API alone gives end-of-decode results.

Acceptance

  • Params::set_progress_callback(impl FnMut(f32)) returning WhisperResult<&mut Self>.
  • Params::set_new_segment_callback(impl FnMut(&Segment<'_>, i32)) — careful: the Segment borrow lifetime is during the callback only.
  • Params::set_filter_logits_callback(impl FnMut(&[Token], &mut [f32])).
  • Params::set_start_encoder_callback(impl FnMut()).
  • Each lifetime-shape decision documented in the corresponding setter's doc.
  • Audit-matrix rows for each new method.
  • Unit tests for set_* (storage / replacement) plus integration tests confirming the callback fires.

If you want streaming partial-result emission, this is the load-bearing piece. Drop a comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions