Add EmitsPartials capability flag for finals-only STT providers - #82
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the shape sketched in #75: an optional
EmitsPartials() boolcapability interface ininternal/stt, type-asserted once inrunInboundand defaulting to true, so finals-only providers get a degraded barge-in instead of none.stt.PartialsEmittersits next toClient; providers that stream interims return true, finals-only providers return false, and providers that don't implement it keep the partials-driven path exactly as before.runInboundasserts once afterstt.NewClient. When false, the backchannel candidate opens on VAD alone, and the interrupt still cannot fire until the full 600msbackchannelWindowhas elapsed: a burst that ends inside the window classifies as backchannel, since there is no partial text to say otherwise. Live captions are unchanged (finals flow as before).openaiClientreturns false (batch transcription);telnyxSessionClientreturns true,telnyxUtteranceClient(the exact-case in-houseTelnyxengine) returns false, the same splitNewTelnyxClientalready uses for socket lifecycle.Why
openai has had dead barge-in since day one and nobody wrote it down; the in-house Telnyx engine shipped the same hole. Waiting for partial text that never arrives means
hasPartialTextnever goes true and the barge-in trigger never fires. VAD-only after the full window is the honest degraded mode: sustained interruptions work, short unclassifiable bursts stay suppressed, and nothing about any other provider changes.Existing-provider safety
For every provider without the interface (and telnyx hosted engines),
emitsPartialsis true and the trigger short-circuits to the originalhasPartialText.Load()expression, same bytes, same frames, same state machine. No dispatch or config schema changes; the only existing-provider edits are theEmitsPartialsmethods, plus rewording the telnyx startup log line and one stale comment that claimed barge-in was off.Tests
internal/stt: plain Client does not satisfyPartialsEmitter(the default-true contract); telnyx true/false by engine throughNewTelnyxClient; openai false.internal/pipeline: hermeticrunInbounddrives: no partial text means no barge-in (current path unchanged); partials plus sustained speech fires; VAD-only holds the interrupt until the window elapses and fires after; a short burst inside the window is suppressed.gofmt -l .,go build ./...,go vet ./...,go test -race ./....Docs
All "barge-in and live captions are off" claims (providers.md and zh-CN, README and zh-CN, configuration.md and zh-CN, the config.toml.example comment, the config.go doc comment, and the telnyx startup log) now describe the degraded mode instead.
Follows #78 (Telnyx STT) and option 3 from #75.