Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RestructureSpeak to Resolve Naming Convention, Update Listen to Match #426

Merged

Conversation

davidvonthenen
Copy link
Contributor

@davidvonthenen davidvonthenen commented Jul 1, 2024

Proposed changes

This performs a similar restructure for speak and also for listen to make the dot notation accessors behave in similar ways. This change provides backward compatibility with deprecation warnings for removal in the next major version.

Although, the PR looks large (was trying to best git mv things to make it look like I was just organizing things), it did work in some cases and in many others, it did not.

deepgram.listen Changes

To demonstrate the approach on this PR, the following changes were made to the listen.

The way it is currently:

deepgram
+-- listen
       +-- prerecorded / v1
              +-- client.py
              +-- async_client.py
              +-- (other files like constants, etc)
       +-- live / v1
              +-- client.py
              +-- async_client.py
              +-- (other files like constants, etc)
       ...

The files were moved into a deepgram.listen.<rest | websocket>.v1 folder, and deepgram.listen.<prerecorded | live>.v1 creates backward-compatible links to artifacts in these new folders.

deepgram
+-- listen
       +-- rest / v1
             +-- [MOVED] client.py
             +-- [MOVED] async_client.py
             +-- [MOVED]  (other files like constants, etc)
       +-- websocket / v1
             +-- [MOVED] client.py
             +-- [MOVED] async_client.py
             +-- [MOVED]  (other files like constants, etc)
       +-- live / v1
              +-- [DEPRECATED] All classes/enums/etc that were there are accessible/referencable
       +-- prerecorded / v1
              +-- [DEPRECATED] All classes/enums/etc that were there are accessible/referencable
       ...

For listen, so to access the classes in the dot notation, it looks like this now:
deepgram.listen.prerecorded.v("1") (old) -> deepgram.listen.rest.v("1") (new)
deepgram.listen.live.v("1") (old) -> deepgram.listen.websocket.v("1") (new)

deepgram.speak Changes

Speak is slightly different since we are implementing TTS WS in this release, we are making the dot notation for access to deepgram.speak.websocket.v("1").

For REST, we are providing backward compatibility just like listen, so the accessors look like this now.
deepgram.speak.v("1") (old) -> deepgram.speak.rest.v("1") (new)

When attempting to use prerecorded, for example, it will still function normally, but you will be greeted with the following warning:

/Users/<user>/go/src/github.com/deepgram/deepgram-python-sdk/examples/speech-to-text/rest/url/main.py:33: DeprecatedWarning: prerecorded is deprecated as of 3.4.0 and will be removed in 4.0.0. deepgram.listen.prerecorded is deprecated. Use deepgram.listen.rest instead.

TODO:

  • The README will be updated in a follow up PR.

Types of changes

What types of changes does your code introduce to the community Python SDK?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update or tests (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have lint'ed all of my code using repo standards
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

NA

Summary by CodeRabbit

  • New Features

    • Introduced WebSocket client capabilities for Deepgram's text-to-speech services.
    • Added new data classes for handling various WebSocket responses.
  • Refactor

    • Renamed various classes and methods to distinguish between REST and WebSocket clients.
    • Updated import paths and event handling logic for consistency.
  • Examples

    • Added new example scripts for using REST and WebSocket clients with Deepgram's text-to-speech services.
  • Dependencies

    • Updated version constraints for multiple packages in requirements.txt.
    • Added the deprecation package in pyproject.toml and setup.py.

Copy link
Contributor

coderabbitai bot commented Jul 1, 2024

Warning

Rate limit exceeded

@dvonthenen has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 40 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between df78073 and 897fdae.

Walkthrough

The changes primarily involve renaming classes and adjusting import paths in Deepgram's client SDK for both REST and WebSocket communication, especially for text-to-speech functionalities. These changes also include adding new response type classes for WebSocket communication, and updating sample scripts for both REST and WebSocket usage. Additionally, there are updates to dependencies in configuration files to ensure compatibility and use of the latest versions.

Changes

Files / Group Change Summary
.../__init__.py Added imports for REST and WebSocket client classes in deepgram/clients/speak/v1/rest and .../websocket/.
async_client.py, client.py Renamed client classes and updated return types from SpeakResponse to SpeakRESTResponse.
helpers.py Updated import statements for SpeakSource in rest and added URL manipulation functions in websocket.
response.py Renamed response classes to use SpeakRESTResponse and added new WebSocket response classes.
.../rest/ Introduced new SpeakRESTClient and AsyncSpeakRESTClient classes in main.py scripts in examples.
.../websocket/ Introduced new SpeakWebSocketClient and AsyncSpeakWebSocketClient classes in main.py scripts in examples.
speak_router.py Added Speak class to provide REST and WebSocket clients for interacting with Deepgram API.
mypy.ini Maintained ignore_missing_imports setting with no functional alterations.
pyproject.toml & requirements.txt Added and updated package version constraints including deprecation, websockets, httpx, etc.
setup.py Added the deprecation package to the dependencies.

Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are currently opted into early access features by default.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@davidvonthenen davidvonthenen merged commit 02f6705 into deepgram:main Jul 2, 2024
5 checks passed
@davidvonthenen davidvonthenen deleted the restructure-listen-and-speak branch July 2, 2024 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants