Skip to content

Conversation

@lukeocodes
Copy link
Contributor

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:

  • Added a new script scripts/patch_websocket_transport.py to automatically patch auto-generated client files, replacing direct websockets imports with imports from a new wrapper module. This allows for easier customization and future-proofing of WebSocket transport logic.
  • Introduced src/deepgram/core/websocket_wrapper.py, which wraps and re-exports key websockets modules and functions. This enables generated code to import WebSocket functionality from a single customizable location.
  • Added a patch-websockets target to the Makefile to run the new patching script conveniently.

Example and Test Improvements:

  • Enhanced the examples/07-transcription-live-websocket.py example 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]
  • Updated .fernignore in tests/manual to ignore .gitignore files, preventing them from being included in test packaging or deployment.

@lukeocodes lukeocodes requested a review from a team December 23, 2025 16:11
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch lo/v6-custom-websocket-transports

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lukeocodes lukeocodes added the wip label Dec 23, 2025
@lukeocodes lukeocodes marked this pull request as draft December 23, 2025 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants