Repository navigation
Conversation
…ge cancelled audio - Eager audio() binding: bind target flush_id and session open state immediately at audio() call time rather than lazily on first iteration, preventing subsequent flush() calls from advancing the request id before playback begins. - Guard against re-reading finished flush_ids: track _done_through and raise ValueError if audio() is called for an id whose FlushDone was already consumed. - Purge and discard stale audio on cancel(): remove pending audio frames from PullBuffer on cancel() and discard in-flight frames arriving for cancelled flush_ids in _dispatch(). - Activity-based terminate() wait: dynamically extend terminate wait as long as the server actively sends frames, timing out only after terminate_timeout of complete silence/inactivity rather than cutting off active synthesis at a flat duration. - Speak backlog guard: enforce text_max_buffer_chars limit before sending text in speak(), and split text into chunked Generate frames within single-frame limits. - Bump version to 1.8.3.
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
Addresses several session synchronization and lifecycle edge cases identified across the Text-to-Speech WebSocket clients (as highlighted in Node SDK #200):
audio()binding: Captures targetflush_idand checks session open state immediately ataudio()call time rather than deferring evaluation to the first iterator step. This ensures that creating a reader before subsequentgenerate()andflush()calls does not inadvertently bind to an advanced or incrementedflush_id.flush_ids: Tracks_done_throughacross consumed requests; callingaudio(flush_id)on an id whoseFlushDonewas already consumed now immediately raises aValueErrorrather than hanging indefinitely waiting on a dead queue.cancel(): Purges pending audio frames fromPullBufferuponcancel()and drops in-flight audio frames arriving for cancelledflush_ids in_dispatch(), preventing cancelled audio from leaking into subsequent iterations.terminate()drain: Replaces the flat cutoff wait interminate()with an activity-based loop that continues waiting as long as the server is actively sending frames, timing out only if no message has arrived forterminate_timeoutseconds.text_max_buffer_charsbefore sending text inspeak()and chunks text exceeding singleGenerateframe limits.1.8.3.Verification
tests/unit/test_tts_session.py,tests/unit/test_tts_session_async.py).audio()request id binding across multiple flushes (sync and async)flush_iderror raisingspeak()buffer backlog limit enforcement and chunkingcancel()ruffand formatted withblack.