feat(websockets): implements custom websocket transport to new v6 architecture #642
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.
This pull request introduces a robust mechanism for patching and customizing WebSocket imports in auto-generated client files, enabling future transport customization without modifying generated code directly. It adds a new script to automate the patching process, a wrapper module for WebSocket-related imports, and improves the live transcription WebSocket example to simulate real-time audio streaming.
WebSocket Transport Customization:
scripts/patch_websocket_transport.pyto automatically patch auto-generated client files, replacing directwebsocketsimports with imports from a new wrapper module. This allows for easier customization and future-proofing of WebSocket transport logic.src/deepgram/core/websocket_wrapper.py, which wraps and re-exports keywebsocketsmodules and functions. This enables generated code to import WebSocket functionality from a single customizable location.patch-websocketstarget to theMakefileto run the new patching script conveniently.Example and Test Improvements:
examples/07-transcription-live-websocket.pyexample to read an audio file, chunk it into 100ms segments, and send the chunks with real-time delays to simulate microphone input. This provides a more realistic demonstration of live transcription via WebSocket. [1] [2] [3].fernignoreintests/manualto ignore.gitignorefiles, preventing them from being included in test packaging or deployment.