Skip to content

Conversation

@joshmux
Copy link

@joshmux joshmux commented Nov 7, 2025

Summary

Fixes an issue in the Go bindings where calling NextSegment() after multiple Process() invocations returns no new segments. This prevented incremental or streaming-style processing from functioning correctly.

Details

When the Go wrapper calls Process() more than once, the internal context segment counter (context.n) is not reset or updated properly. As a result:

  • NextSegment() stops yielding new segments after the first Process() call.
  • Incremental processing workflows (e.g., feeding audio in chunks) silently fail.
  • The behavior diverges from expectations set by the underlying C++ implementation.

This PR resets context.n at the start of each Process() call, ensuring that segment iteration works correctly across multiple processing passes.

Impact

  • Enables proper streaming and incremental recognition in the Go bindings.
  • Prevents confusing silent failures where no segments are returned.
  • Improves consistency and correctness relative to whisper.cpp core behavior.

Backward Compatibility

This change is internal to the Go bindings and does not modify the public API.
Existing code using a single Process()NextSegment() workflow will behave exactly as before.

@joshmux joshmux changed the title Allow for NextSegment to be called for multiple Process calls Allow NextSegment() to be called across multiple Process() calls in the Go binding Nov 19, 2025
@ggerganov
Copy link
Member

Could you take a look at why the Go CI is failing: https://github.com/ggml-org/whisper.cpp/actions/runs/19177622631/job/55919700774?pr=3503

@joshmux
Copy link
Author

joshmux commented Nov 20, 2025

It looks like it's failing to load the model?

whisper_model_load: ERROR not all tensors loaded from model file - expected 479, got 477
whisper_init_with_params_no_state: failed to load model
    whisper_test.go:51: 
        	Error Trace:	/home/runner/work/whisper.cpp/whisper.cpp/bindings/go/whisper_test.go:51
        	Error:      	Expected value not to be nil.
        	Test:       	Test_Whisper_001

Yea, this error happens before we even try to run context.Process.

@joshmux
Copy link
Author

joshmux commented Nov 20, 2025

I think my fork being a few weeks out of date might be causing this issue. Just merged with upstream/master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants