Skip to content

Dart device SDK Whisper drops the batch being transcribed when stop() is called #22393

Open

Description

@apoorvdarshan

Product impact (see PRODUCT.md and ISSUE_TRIAGE_GUIDE.MD)

  • Primary loop layer: Capture (Dart device SDK, local Whisper transcription)
  • Involves data loss, failed capture, or broken sync/trust: stopping while a batch is being transcribed loses up to 5 s of transcript without an error.

Describe the bug

In the Dart device SDK (sdks/device/dart), WhisperTranscriber.appendPcm hands each full batch (5 s by default) to the injected runner without awaiting it, and _flush drops the runner's result when it resolves after stop() has set _stopped. stop() only transcribes the audio that is still buffered. So if stop() is called while a batch is being transcribed, that batch's transcript is discarded, only the tail is delivered, and stop() completes before the batch finishes.

This is the Dart counterpart of #12964 (TypeScript, fixed by #20407) and #13618 (React Native, fixed by #13619). #21577 covers the Python SDK.

To Reproduce

final t = WhisperTranscriber(runner: (_) => 'hello', onTranscript: print, batchSeconds: 1);
t.appendPcm(Uint8List(32000)); // one full 1 s batch of 16 kHz PCM16
await t.stop();

A real runner (an async native Whisper call) loses its batch the same way whenever stop() arrives while it is still running.

Current behavior

Nothing is printed. The runner is called with the full batch, but _flush resumes after stop() has set _stopped and drops the result. With an async runner, the batch that was being transcribed is lost and only the tail is delivered.

Expected behavior

hello is printed before stop() completes. stop() should deliver a batch that is still being transcribed, then the buffered tail, in that order, and complete once every transcript has been delivered, as the TypeScript and React Native SDKs now do.

Evidence (upstream main at 267b255cc812d16598d5fab8d3963766f3672966)

I have a fix with a regression test and will open a PR.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions