docs: add production-grade live transcription reconnection example - #776
Open
dg-coreylweathers wants to merge 1 commit into
Open
docs: add production-grade live transcription reconnection example#776dg-coreylweathers wants to merge 1 commit into
dg-coreylweathers wants to merge 1 commit into
Conversation
Adds examples/17-transcription-live-reconnect.py demonstrating the resilience patterns recommended for production streaming STT: exponential backoff with full jitter and a retry cap, reconnect-worthy close codes distinguished from normal/fatal closure, audio buffered across the disconnect gap and resumed on reconnect, original connection options re-applied, continuous timestamps across sessions, and clean shutdown via CloseStream. Includes a demo-only fault injector that severs the TCP socket mid-stream to show recovery; validated live against api.deepgram.com. Also lists the previously missing example 16 in examples/README.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
dg-coreylweathers
requested review from
GregHolmes and
deepgram-kiley
as code owners
August 31, 2026 13:30
Contributor
|
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.
What
Adds
examples/17-transcription-live-reconnect.py— the canonical production-grade reconnection example for streaming speech-to-text, intended to back the upcomingspeech-to-text/streaming/guides/productiondocs page. Also adds the previously missing README entry for example 16.What it demonstrates
SIMULATE_DROP=0disables it) that severs the TCP socket mid-stream to demonstrate recoveryUses only this SDK's listen v1 socket client; every method and event name verified against source.
Validation (live against api.deepgram.com, in Docker)
close code 1006), resumes with continuous timestamps, exits 0Review
Passed devrel-review: initial pass found 1 blocking (deque-iteration race in buffer telemetry) and 3 should-fixes — all fixed and re-verified live. Final verdict: approve, two accepted nits (fenced
_websocketaccess in the demo fault injector; Ctrl-C during backoff tracebacks).Related finding (not addressed here)
The review's bad-key probe surfaced a pre-existing SDK bug:
core/websocket_compat.pybinds the legacyInvalidStatusCodewhile the sync client raises the distinctInvalidStatus, so rejected websocket handshakes never become the documentedApiErroron any connect path (websockets 12–15). This example tolerates both exception shapes; the SDK-side fix is routed to Greg (generator fix vs hand-patch +.fernignorefreeze).🤖 Generated with Claude Code