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

adds TTS streaming clients #424

Merged
merged 1 commit into from
Jun 27, 2024
Merged

adds TTS streaming clients #424

merged 1 commit into from
Jun 27, 2024

Conversation

SandraRodgers
Copy link
Contributor

@SandraRodgers SandraRodgers commented Jun 24, 2024

Proposed changes

  • The speak API is updated to include the websockets streaming functionality for TTS
  • Two clients are added: streaming client and async streaming client for TTS
  • Two examples to demonstrate how to use these clients

Summary by CodeRabbit

  • New Features

    • Introduced support for Deepgram's text-to-speech services via new SpeakStreamClient and AsyncSpeakStreamClient classes.
    • Added event handling for real-time TTS synthesis.
  • Bug Fixes

    • Improved exception handling and task management in the AsyncLiveClient.
  • Documentation

    • Added examples demonstrating how to interact with Deepgram's speech-to-text service using WebSockets.
  • Refactor

    • Updated error messages to accurately reflect the context of TTS synthesis.
    • Optimized event handling logic to reduce redundant operations.

Copy link
Contributor

coderabbitai bot commented Jun 24, 2024

Walkthrough

The recent enhancements to the Deepgram codebase involve the introduction of new classes for handling real-time speech synthesis via WebSockets. This includes the addition of SpeakStreamClient and AsyncSpeakStreamClient to enable synchronous and asynchronous interactions, respectively, along with event handling for various TTS synthesis events. Several new files and imports have been introduced to support these capabilities, and there are significant improvements to event handling logic in the asynchronous client.

Changes

File/Module Change Summary
deepgram/__init__.py Added imports for SpeakStreamClient, AsyncSpeakStreamClient, and SpeakStreamEvents.
deepgram/client.py Added SpeakStreamClient, AsyncSpeakStreamClient, SpeakStreamEvents imports; new properties speakstream and asyncspeakstream. Updated the v method to handle new cases.
deepgram/clients/__init__.py Added imports for SpeakStreamEvents, SpeakStreamClient, and AsyncSpeakStreamClient.
deepgram/clients/live/v1/async_client.py Updated event handling logic for adding handlers and optimized task creation and handling during event emission. Enhanced exception handling.
deepgram/clients/speak/__init__.py Added SpeakStreamClient, AsyncSpeakStreamClient exports, and imported SpeakStreamEvents.
deepgram/clients/speak/client.py Updated declarations of SpeakStreamClient and AsyncSpeakStreamClient to latest versions.
deepgram/clients/speak/enums.py New file defining SpeakStreamEvents enumeration.
deepgram/clients/speak/errors.py Updated error message in DeepgramTypeError class.
deepgram/clients/speak/v1/__init__.py Added imports for SpeakStreamClient and AsyncSpeakStreamClient.
deepgram/clients/speak/v1/async_client_stream.py New file introducing AsyncSpeakStreamClient with methods for managing TTS synthesis over WebSockets.
deepgram/clients/speak/v1/client_stream.py New file introducing SpeakStreamClient with methods and attributes for WebSocket-based TTS synthesis.
deepgram/clients/speak/v1/response.py Added new data classes for various response types (OpenResponse, MetadataResponse, FlushedResponse, etc.).
examples/speak-stream/async-interactive/main.py New example for setting up a client to interact with TTS service asynchronously, handling various events and data processing.
examples/speak-stream/interactive/main.py New example for setting up a client to interact with TTS service synchronously, handling several streaming events.

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.

@SandraRodgers
Copy link
Contributor Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jun 25, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 15

Outside diff range and nitpick comments (1)
deepgram/clients/speak/__init__.py (1)

Line range hint 6-16: Consider declaring imported modules in __all__ to avoid unused import warnings.

Similar to the previous file, these imports are flagged as unused. If these modules are intended for external use, adding them to the __all__ list can clarify their purpose and prevent linting errors.

+ __all__ = ['SpeakStreamClient', 'AsyncSpeakStreamClient', 'SpeakStreamEvents']
Tools
Ruff

5-5: .client.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


7-7: .client.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: .client.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .client.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 102b807 and 234f05c.

Files selected for processing (13)
  • deepgram/init.py (1 hunks)
  • deepgram/client.py (5 hunks)
  • deepgram/clients/init.py (1 hunks)
  • deepgram/clients/speak/init.py (2 hunks)
  • deepgram/clients/speak/client.py (2 hunks)
  • deepgram/clients/speak/enums.py (1 hunks)
  • deepgram/clients/speak/errors.py (1 hunks)
  • deepgram/clients/speak/v1/init.py (1 hunks)
  • deepgram/clients/speak/v1/async_client_stream.py (1 hunks)
  • deepgram/clients/speak/v1/client_stream.py (1 hunks)
  • deepgram/clients/speak/v1/response.py (1 hunks)
  • examples/speak-stream/async-interactive/main.py (1 hunks)
  • examples/speak-stream/interactive/main.py (1 hunks)
Files skipped from review due to trivial changes (2)
  • deepgram/clients/speak/enums.py
  • deepgram/clients/speak/errors.py
Additional context used
Ruff
deepgram/clients/speak/v1/__init__.py

5-5: .client.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client_stream.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


7-7: .async_client_stream.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: .async_client.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .options.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .options.FileSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .options.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .options.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


10-10: .response.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: ....options.DeepgramClientOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: ....options.ClientOptionsFromEnv imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/clients/speak/__init__.py

5-5: .client.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


7-7: .client.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: .client.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .client.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


11-11: .client.FileSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: .client.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


13-13: .client.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


16-16: .enums.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


17-17: ...options.DeepgramClientOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


17-17: ...options.ClientOptionsFromEnv imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/clients/__init__.py

7-7: .common.TextSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: .common.BufferSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .common.StreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


10-10: .common.FileSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


11-11: .common.UrlSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: .common.Sentiment imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


16-16: .listen.Listen imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


17-17: .read.Read imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


20-20: .live.LiveClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


20-20: .live.AsyncLiveClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


21-21: .live.LiveOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


22-22: .live.LiveTranscriptionEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


24-24: .live.OpenResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


25-25: .live.LiveResultResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


26-26: .live.MetadataResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


27-27: .live.SpeechStartedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


28-28: .live.UtteranceEndResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


29-29: .live.CloseResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


30-30: .live.ErrorResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


31-31: .live.UnhandledResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


35-35: .prerecorded.PreRecordedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


35-35: .prerecorded.AsyncPreRecordedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


36-36: .prerecorded.PrerecordedOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


38-38: .prerecorded.PreRecordedStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


39-39: .prerecorded.PrerecordedSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


42-42: .prerecorded.AsyncPrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


43-43: .prerecorded.PrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


44-44: .prerecorded.SyncPrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


48-48: .analyze.ReadClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


48-48: .analyze.AsyncReadClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


49-49: .analyze.AnalyzeClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


49-49: .analyze.AsyncAnalyzeClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


50-50: .analyze.AnalyzeOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


52-52: .analyze.AnalyzeStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


53-53: .analyze.AnalyzeSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


56-56: .analyze.AsyncAnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


57-57: .analyze.AnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


58-58: .analyze.SyncAnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


62-62: .speak.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


62-62: .speak.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


63-63: .speak.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


65-65: .speak.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


66-66: .speak.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


68-68: .speak.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


69-69: .speak.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .speak.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .speak.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


75-75: .manage.ManageClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


75-75: .manage.AsyncManageClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


77-77: .manage.ProjectOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


78-78: .manage.KeyOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


79-79: .manage.ScopeOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


80-80: .manage.InviteOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


81-81: .manage.UsageRequestOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


82-82: .manage.UsageSummaryOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


83-83: .manage.UsageFieldsOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


86-86: .manage.Message imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .manage.Project imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


88-88: .manage.ProjectsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


89-89: .manage.MembersResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


90-90: .manage.Key imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


91-91: .manage.KeyResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


92-92: .manage.KeysResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


93-93: .manage.ScopesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


94-94: .manage.InvitesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


95-95: .manage.UsageRequest imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


96-96: .manage.UsageRequestsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


97-97: .manage.UsageSummaryResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


98-98: .manage.UsageFieldsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


99-99: .manage.Balance imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


100-100: .manage.BalancesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


105-105: .selfhosted.OnPremClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


106-106: .selfhosted.AsyncOnPremClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


107-107: .selfhosted.SelfHostedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


108-108: .selfhosted.AsyncSelfHostedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/__init__.py

9-9: logging imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


10-10: .utils.VerboseLogger imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: .utils.NOTICE imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


13-13: .utils.SPAM imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


14-14: .utils.SUCCESS imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


15-15: .utils.VERBOSE imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


16-16: .utils.WARNING imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


17-17: .utils.ERROR imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


18-18: .utils.FATAL imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


19-19: .utils.CRITICAL imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


20-20: .utils.INFO imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


21-21: .utils.DEBUG imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


22-22: .utils.NOTSET imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


25-25: .client.Deepgram imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


25-25: .client.DeepgramClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


26-26: .client.DeepgramClientOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


26-26: .client.ClientOptionsFromEnv imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


27-27: .client.DeepgramApiKeyError imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


27-27: .client.DeepgramModuleError imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


30-30: .client.Listen imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


30-30: .client.Read imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


34-34: .client.TextSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


35-35: .client.BufferSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


36-36: .client.StreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


37-37: .client.FileSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


38-38: .client.UrlSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


39-39: .client.Sentiment imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


43-43: .client.LiveTranscriptionEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


44-44: .client.LiveClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


44-44: .client.AsyncLiveClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


45-45: .client.LiveOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


47-47: .client.OpenResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


48-48: .client.LiveResultResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


49-49: .client.MetadataResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


50-50: .client.SpeechStartedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


51-51: .client.UtteranceEndResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


52-52: .client.CloseResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


53-53: .client.UnhandledResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


54-54: .client.ErrorResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


58-58: .client.PreRecordedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


58-58: .client.AsyncPreRecordedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


60-60: .client.PrerecordedOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


61-61: .client.PreRecordedStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


62-62: .client.PrerecordedSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


65-65: .client.AsyncPrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


66-66: .client.PrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


67-67: .client.SyncPrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


71-71: .client.ReadClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


71-71: .client.AsyncReadClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .client.AnalyzeClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .client.AsyncAnalyzeClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


74-74: .client.AnalyzeOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


75-75: .client.AnalyzeStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


76-76: .client.AnalyzeSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


79-79: .client.AsyncAnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


80-80: .client.AnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


81-81: .client.SyncAnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


85-85: .client.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


85-85: .client.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


86-86: .client.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


86-86: .client.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .client.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .client.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .client.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


88-88: .client.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


89-89: .client.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


92-92: .client.ManageClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


92-92: .client.AsyncManageClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


94-94: .client.ProjectOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


95-95: .client.KeyOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


96-96: .client.ScopeOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


97-97: .client.InviteOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


98-98: .client.UsageRequestOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


99-99: .client.UsageSummaryOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


100-100: .client.UsageFieldsOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


105-105: .client.Message imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


106-106: .client.Project imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


107-107: .client.ProjectsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


108-108: .client.MembersResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


109-109: .client.Key imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


110-110: .client.KeyResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


111-111: .client.KeysResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


112-112: .client.ScopesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


113-113: .client.InvitesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


114-114: .client.UsageRequest imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


115-115: .client.UsageRequestsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


116-116: .client.UsageSummaryResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


117-117: .client.UsageFieldsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


118-118: .client.Balance imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


119-119: .client.BalancesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


124-124: .client.OnPremClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


125-125: .client.AsyncOnPremClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


126-126: .client.SelfHostedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


127-127: .client.AsyncSelfHostedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


131-131: .audio.Microphone imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


133-133: .audio.LOGGING imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


134-134: .audio.CHANNELS imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


135-135: .audio.RATE imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


136-136: .audio.CHUNK imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

examples/speak-stream/async-interactive/main.py

3-3: json imported but unused (F401)

Remove unused import: json

examples/speak-stream/interactive/main.py

8-8: json imported but unused (F401)

Remove unused import: json

deepgram/client.py

15-15: .clients.TextSource imported but unused (F401)

Remove unused import


16-16: .clients.BufferSource imported but unused (F401)

Remove unused import


17-17: .clients.StreamSource imported but unused (F401)

Remove unused import


18-18: .clients.FileSource imported but unused (F401)

Remove unused import


19-19: .clients.UrlSource imported but unused (F401)

Remove unused import


20-20: .clients.Sentiment imported but unused (F401)

Remove unused import


27-27: .clients.LiveClient imported but unused (F401)

Remove unused import


27-27: .clients.AsyncLiveClient imported but unused (F401)

Remove unused import


29-29: .clients.LiveOptions imported but unused (F401)

Remove unused import


30-30: .clients.LiveTranscriptionEvents imported but unused (F401)

Remove unused import


35-35: .clients.OpenResponse imported but unused (F401)

Remove unused import


36-36: .clients.LiveResultResponse imported but unused (F401)

Remove unused import


37-37: .clients.MetadataResponse imported but unused (F401)

Remove unused import


38-38: .clients.SpeechStartedResponse imported but unused (F401)

Remove unused import


39-39: .clients.UtteranceEndResponse imported but unused (F401)

Remove unused import


40-40: .clients.CloseResponse imported but unused (F401)

Remove unused import


41-41: .clients.ErrorResponse imported but unused (F401)

Remove unused import


42-42: .clients.UnhandledResponse imported but unused (F401)

Remove unused import


47-47: .clients.PreRecordedClient imported but unused (F401)

Remove unused import


48-48: .clients.AsyncPreRecordedClient imported but unused (F401)

Remove unused import


51-51: .clients.PrerecordedOptions imported but unused (F401)

Remove unused import


52-52: .clients.PreRecordedStreamSource imported but unused (F401)

Remove unused import


53-53: .clients.PrerecordedSource imported but unused (F401)

Remove unused import


58-58: .clients.AsyncPrerecordedResponse imported but unused (F401)

Remove unused import


59-59: .clients.PrerecordedResponse imported but unused (F401)

Remove unused import


60-60: .clients.SyncPrerecordedResponse imported but unused (F401)

Remove unused import


64-64: .clients.ReadClient imported but unused (F401)

Remove unused import


64-64: .clients.AsyncReadClient imported but unused (F401)

Remove unused import


65-65: .clients.AnalyzeClient imported but unused (F401)

Remove unused import


65-65: .clients.AsyncAnalyzeClient imported but unused (F401)

Remove unused import


67-67: .clients.AnalyzeOptions imported but unused (F401)

Remove unused import


68-68: .clients.AnalyzeStreamSource imported but unused (F401)

Remove unused import


69-69: .clients.AnalyzeSource imported but unused (F401)

Remove unused import


74-74: .clients.AsyncAnalyzeResponse imported but unused (F401)

Remove unused import


75-75: .clients.AnalyzeResponse imported but unused (F401)

Remove unused import


76-76: .clients.SyncAnalyzeResponse imported but unused (F401)

Remove unused import


80-80: .clients.SpeakClient imported but unused (F401)

Remove unused import


80-80: .clients.AsyncSpeakClient imported but unused (F401)

Remove unused import


81-81: .clients.SpeakStreamClient imported but unused (F401)

Remove unused import


81-81: .clients.AsyncSpeakStreamClient imported but unused (F401)

Remove unused import


82-82: .clients.SpeakOptions imported but unused (F401)

Remove unused import: .clients.SpeakOptions


83-83: .clients.SpeakStreamSource imported but unused (F401)

Remove unused import


83-83: .clients.SpeakSource imported but unused (F401)

Remove unused import


84-84: .clients.SpeakStreamEvents imported but unused (F401)

Remove unused import: .clients.SpeakStreamEvents


87-87: .clients.SpeakResponse imported but unused (F401)

Remove unused import: .clients.SpeakResponse


90-90: .clients.ManageClient imported but unused (F401)

Remove unused import


90-90: .clients.AsyncManageClient imported but unused (F401)

Remove unused import


92-92: .clients.ProjectOptions imported but unused (F401)

Remove unused import


93-93: .clients.KeyOptions imported but unused (F401)

Remove unused import


94-94: .clients.ScopeOptions imported but unused (F401)

Remove unused import


95-95: .clients.InviteOptions imported but unused (F401)

Remove unused import


96-96: .clients.UsageRequestOptions imported but unused (F401)

Remove unused import


97-97: .clients.UsageSummaryOptions imported but unused (F401)

Remove unused import


98-98: .clients.UsageFieldsOptions imported but unused (F401)

Remove unused import


103-103: .clients.Message imported but unused (F401)

Remove unused import


104-104: .clients.Project imported but unused (F401)

Remove unused import


105-105: .clients.ProjectsResponse imported but unused (F401)

Remove unused import


106-106: .clients.MembersResponse imported but unused (F401)

Remove unused import


107-107: .clients.Key imported but unused (F401)

Remove unused import


108-108: .clients.KeyResponse imported but unused (F401)

Remove unused import


109-109: .clients.KeysResponse imported but unused (F401)

Remove unused import


110-110: .clients.ScopesResponse imported but unused (F401)

Remove unused import


111-111: .clients.InvitesResponse imported but unused (F401)

Remove unused import


112-112: .clients.UsageRequest imported but unused (F401)

Remove unused import


113-113: .clients.UsageRequestsResponse imported but unused (F401)

Remove unused import


114-114: .clients.UsageSummaryResponse imported but unused (F401)

Remove unused import


115-115: .clients.UsageFieldsResponse imported but unused (F401)

Remove unused import


116-116: .clients.Balance imported but unused (F401)

Remove unused import


117-117: .clients.BalancesResponse imported but unused (F401)

Remove unused import


122-122: .clients.OnPremClient imported but unused (F401)

Remove unused import


123-123: .clients.AsyncOnPremClient imported but unused (F401)

Remove unused import


124-124: .clients.SelfHostedClient imported but unused (F401)

Remove unused import


125-125: .clients.AsyncSelfHostedClient imported but unused (F401)

Remove unused import


129-129: .options.ClientOptionsFromEnv imported but unused (F401)

Remove unused import: .options.ClientOptionsFromEnv


130-130: .errors.DeepgramApiKeyError imported but unused (F401)

Remove unused import: .errors.DeepgramApiKeyError

Additional comments not posted (8)
deepgram/clients/speak/client.py (1)

Line range hint 7-35: Updated class references to latest versions are correctly implemented.

The imports and aliases are correctly updated to reference the latest versions of the classes, which aligns with the SDK's versioning strategy to support backward compatibility.

deepgram/client.py (1)

81-84: Introduction of SpeakStreamClient and AsyncSpeakStreamClient

The introduction of SpeakStreamClient and AsyncSpeakStreamClient properties in the DeepgramClient class is a significant enhancement, aligning with the new feature set of TTS streaming. Here are a few points to consider:

  1. Documentation: The documentation for these new properties is clear and concise, explaining their purpose and usage well.
  2. Error Handling: Consider adding error handling within the Version class methods to manage cases where the module or class cannot be found, as this could lead to runtime errors.
  3. Testing: Ensure that these new properties are covered by unit tests, particularly testing edge cases and error scenarios.

These additions are crucial for supporting the new TTS streaming functionality and are implemented correctly in the context of the existing SDK architecture.

Also applies to: 241-253

Tools
Ruff

81-81: .clients.SpeakStreamClient imported but unused (F401)

Remove unused import


81-81: .clients.AsyncSpeakStreamClient imported but unused (F401)

Remove unused import


82-82: .clients.SpeakOptions imported but unused (F401)

Remove unused import: .clients.SpeakOptions


83-83: .clients.SpeakStreamSource imported but unused (F401)

Remove unused import


83-83: .clients.SpeakSource imported but unused (F401)

Remove unused import


84-84: .clients.SpeakStreamEvents imported but unused (F401)

Remove unused import: .clients.SpeakStreamEvents

deepgram/clients/speak/v1/client_stream.py (5)

190-198: Validate event handler registration in the on method.

The on method correctly checks if the event is valid and if the handler is callable before appending it to the event handlers list. This prevents potential runtime errors and ensures that only valid handlers are registered.


216-386: Optimize the _listening method's exception handling and control flow.

The _listening method is designed to continuously listen for messages from the WebSocket connection. However, the method's exception handling and control flow can be optimized to reduce redundancy and improve clarity.
[REFACTOR_Suggestion]

- except websockets.exceptions.ConnectionClosed as e:
-     if e.code == 1000:
-         self._logger.notice(f"_listening({e.code}) exiting gracefully")
-         self._logger.debug("SpeakStreamClient._listening LEAVE")
-         return
-     self._logger.error(
-         "ConnectionClosed in SpeakStreamClient._listening with code %s: %s",
-         e.code,
-         e.reason,
-     )
-     cc_error: ErrorResponse = ErrorResponse(
-         "ConnectionClosed in SpeakStreamClient._listening",
-         f"{e}",
-         "ConnectionClosed",
-     )
-     self._emit(
-         SpeakStreamEvents(SpeakStreamEvents.Error), cc_error
-     )
-     # signal exit and close
-     self._signal_exit()
-     self._logger.debug("SpeakStreamClient._listening LEAVE")
-     if self._config.options.get("termination_exception") == "true":
-         raise
-     return
+ except websockets.exceptions.ConnectionClosed as e:
+     self._handle_connection_closed(e)

Create a new method _handle_connection_closed to handle ConnectionClosed exceptions, which will centralize the error handling and make the code cleaner.


390-445: Review the send method's error handling and socket check.

The send method includes comprehensive error handling for various WebSocket exceptions. However, the method first checks if the socket is not None before proceeding, which is a good practice to avoid NoneType errors.


450-477: Ensure robustness in the flush method.

The flush method attempts to send a "Flush" command via the WebSocket connection. It correctly checks the return value to determine if the flush was successful. This method is crucial for ensuring that all pending data is sent before closing the connection.


480-508: Validate the finish method's thread management and cleanup.

The finish method handles the graceful closure of the WebSocket connection and ensures that all associated threads are properly joined. This is crucial for avoiding resource leaks and ensuring that the application exits cleanly.

deepgram/clients/speak/v1/async_client_stream.py (1)

77-183: Review the start method for error handling and logic flow.

  • The method logs extensively, which is good for debugging, but ensure that logging does not expose sensitive information.
  • The method handles different types of exceptions and re-raises them based on a configuration option. This is a flexible error handling strategy but verify that it is consistent with the overall error handling strategy of the SDK.
  • The use of isinstance checks for SpeakOptions could be streamlined by ensuring options is always a valid instance or None.

deepgram/clients/speak/v1/async_client_stream.py Outdated Show resolved Hide resolved
deepgram/clients/speak/v1/async_client_stream.py Outdated Show resolved Hide resolved
deepgram/clients/speak/v1/__init__.py Show resolved Hide resolved
deepgram/clients/speak/v1/async_client_stream.py Outdated Show resolved Hide resolved
deepgram/clients/speak/v1/client_stream.py Show resolved Hide resolved
examples/speak-stream/async-interactive/main.py Outdated Show resolved Hide resolved
examples/speak-stream/interactive/main.py Outdated Show resolved Hide resolved
examples/speak-stream/interactive/main.py Outdated Show resolved Hide resolved
deepgram/clients/speak/v1/response.py Outdated Show resolved Hide resolved
Copy link
Contributor

@dvonthenen dvonthenen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than that plus the existing coderabbit stuff (already dismissed a bunch of stuff we don't want to tackle right now), this looks great!

It's just the coderabbit stuff now. I think we are good to go after those updates.

deepgram/clients/speak/enums.py Show resolved Hide resolved
@SandraRodgers SandraRodgers force-pushed the sr/TTS-streaming-API branch 2 times, most recently from 1ff0e05 to a53a297 Compare June 26, 2024 22:25
@SandraRodgers SandraRodgers marked this pull request as ready for review June 26, 2024 22:26
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

Outside diff range and nitpick comments (2)
deepgram/client.py (1)

Line range hint 15-15: Suggestion to remove unused imports.

The static analysis has identified multiple imports that are currently unused. Removing these can help clean up the codebase and potentially improve the module's load time and memory usage.

- from .clients import TextSource, BufferSource, StreamSource, FileSource, UrlSource, Sentiment, LiveClient, AsyncLiveClient, LiveOptions, LiveTranscriptionEvents, OpenResponse, LiveResultResponse, MetadataResponse, SpeechStartedResponse, UtteranceEndResponse, CloseResponse, ErrorResponse, UnhandledResponse, PreRecordedClient, AsyncPreRecordedClient, PrerecordedOptions, PreRecordedStreamSource, PrerecordedSource, AsyncPrerecordedResponse, PrerecordedResponse, SyncPrerecordedResponse, ReadClient, AsyncReadClient, AnalyzeClient, AsyncAnalyzeClient, AnalyzeOptions, AnalyzeStreamSource, AnalyzeSource, AsyncAnalyzeResponse, AnalyzeResponse, SyncAnalyzeResponse, SpeakClient, AsyncSpeakClient, SpeakStreamClient, AsyncSpeakStreamClient, SpeakOptions, SpeakStreamSource, SpeakSource, SpeakStreamEvents, SpeakResponse, ManageClient, AsyncManageClient, ProjectOptions, KeyOptions, ScopeOptions, InviteOptions, UsageRequestOptions, UsageSummaryOptions, UsageFieldsOptions, Message, Project, ProjectsResponse, MembersResponse, Key, KeyResponse, KeysResponse, ScopesResponse, InvitesResponse, UsageRequest, UsageRequestsResponse, UsageSummaryResponse, UsageFieldsResponse, Balance, BalancesResponse, OnPremClient, AsyncOnPremClient, SelfHostedClient, AsyncSelfHostedClient, ClientOptionsFromEnv, DeepgramApiKeyError

Also applies to: 16-16, 17-17, 18-18, 19-19, 20-20, 27-27, 27-27, 29-29, 30-30, 35-35, 36-36, 37-37, 38-38, 39-39, 40-40, 41-41, 42-42, 47-47, 48-48, 51-51, 52-52, 53-53, 58-58, 59-59, 60-60, 64-64, 64-64, 65-65, 65-65, 67-67, 68-68, 69-69, 74-74, 75-75, 76-76, 80-80, 80-80, 81-81, 81-81, 82-82, 83-83, 83-83, 84-84, 87-87, 87-87, 92-92, 93-93, 94-94, 95-95, 96-96, 97-97, 98-98, 103-103, 104-104, 105-105, 106-106, 107-107, 108-108, 109-109, 110-110, 111-111, 112-112, 113-113, 114-114, 115-115, 116-116, 117-117, 122-122, 123-123, 124-124, 125-125, 129-129, 130-130

Tools
Ruff

80-80: .clients.SpeakClient imported but unused (F401)

Remove unused import


80-80: .clients.AsyncSpeakClient imported but unused (F401)

Remove unused import


81-81: .clients.SpeakStreamClient imported but unused (F401)

Remove unused import


81-81: .clients.AsyncSpeakStreamClient imported but unused (F401)

Remove unused import


82-82: .clients.SpeakOptions imported but unused (F401)

Remove unused import: .clients.SpeakOptions


83-83: .clients.SpeakStreamSource imported but unused (F401)

Remove unused import


83-83: .clients.SpeakSource imported but unused (F401)

Remove unused import


84-84: .clients.SpeakStreamEvents imported but unused (F401)

Remove unused import: .clients.SpeakStreamEvents


87-87: .clients.SpeakResponse imported but unused (F401)

Remove unused import: .clients.SpeakResponse

deepgram/clients/speak/v1/async_client_stream.py (1)

228-417: Enhance error handling in the _listening method.

Ensure robust error handling for different WebSocket exceptions. Consider adding specific error handling for different WebSocket error codes to improve the method's resilience.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 234f05c and a53a297.

Files selected for processing (14)
  • deepgram/init.py (1 hunks)
  • deepgram/client.py (5 hunks)
  • deepgram/clients/init.py (1 hunks)
  • deepgram/clients/live/v1/async_client.py (3 hunks)
  • deepgram/clients/speak/init.py (2 hunks)
  • deepgram/clients/speak/client.py (2 hunks)
  • deepgram/clients/speak/enums.py (1 hunks)
  • deepgram/clients/speak/errors.py (1 hunks)
  • deepgram/clients/speak/v1/init.py (1 hunks)
  • deepgram/clients/speak/v1/async_client_stream.py (1 hunks)
  • deepgram/clients/speak/v1/client_stream.py (1 hunks)
  • deepgram/clients/speak/v1/response.py (1 hunks)
  • examples/speak-stream/async-interactive/main.py (1 hunks)
  • examples/speak-stream/interactive/main.py (1 hunks)
Files skipped from review as they are similar to previous changes (5)
  • deepgram/clients/speak/client.py
  • deepgram/clients/speak/enums.py
  • deepgram/clients/speak/errors.py
  • deepgram/clients/speak/v1/response.py
  • examples/speak-stream/async-interactive/main.py
Additional context used
Learnings (2)
deepgram/clients/speak/v1/client_stream.py (2)
User: dvonthenen
PR: deepgram/deepgram-python-sdk#424
File: deepgram/clients/speak/v1/client_stream.py:59-79
Timestamp: 2024-06-25T15:26:40.699Z
Learning: The `config` object is always created before being passed to the `SpeakStreamClient` constructor, and should not be `null`.
User: dvonthenen
PR: deepgram/deepgram-python-sdk#424
File: deepgram/clients/speak/v1/async_client_stream.py:55-74
Timestamp: 2024-06-25T15:18:16.852Z
Learning: The `config` parameter in the `AsyncSpeakStreamClient` constructor should not be optional and must be enforced at the type level.
deepgram/clients/speak/v1/async_client_stream.py (2)
User: dvonthenen
PR: deepgram/deepgram-python-sdk#424
File: deepgram/clients/speak/v1/async_client_stream.py:55-74
Timestamp: 2024-06-25T15:18:16.852Z
Learning: The `config` parameter in the `AsyncSpeakStreamClient` constructor should not be optional and must be enforced at the type level.
User: dvonthenen
PR: deepgram/deepgram-python-sdk#424
File: deepgram/clients/speak/v1/client_stream.py:59-79
Timestamp: 2024-06-25T15:26:40.699Z
Learning: The `config` object is always created before being passed to the `SpeakStreamClient` constructor, and should not be `null`.
Ruff
deepgram/clients/speak/v1/__init__.py

5-5: .client.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client_stream.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


7-7: .async_client_stream.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: .async_client.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .options.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .options.FileSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .options.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .options.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


10-10: .response.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: ....options.DeepgramClientOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: ....options.ClientOptionsFromEnv imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/clients/speak/__init__.py

5-5: .client.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


7-7: .client.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: .client.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .client.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


11-11: .client.FileSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: .client.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


13-13: .client.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


16-16: .enums.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


17-17: ...options.DeepgramClientOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


17-17: ...options.ClientOptionsFromEnv imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/clients/__init__.py

7-7: .common.TextSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: .common.BufferSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .common.StreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


10-10: .common.FileSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


11-11: .common.UrlSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: .common.Sentiment imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


16-16: .listen.Listen imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


17-17: .read.Read imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


20-20: .live.LiveClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


20-20: .live.AsyncLiveClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


21-21: .live.LiveOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


22-22: .live.LiveTranscriptionEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


24-24: .live.OpenResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


25-25: .live.LiveResultResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


26-26: .live.MetadataResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


27-27: .live.SpeechStartedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


28-28: .live.UtteranceEndResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


29-29: .live.CloseResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


30-30: .live.ErrorResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


31-31: .live.UnhandledResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


35-35: .prerecorded.PreRecordedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


35-35: .prerecorded.AsyncPreRecordedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


36-36: .prerecorded.PrerecordedOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


38-38: .prerecorded.PreRecordedStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


39-39: .prerecorded.PrerecordedSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


42-42: .prerecorded.AsyncPrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


43-43: .prerecorded.PrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


44-44: .prerecorded.SyncPrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


48-48: .analyze.ReadClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


48-48: .analyze.AsyncReadClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


49-49: .analyze.AnalyzeClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


49-49: .analyze.AsyncAnalyzeClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


50-50: .analyze.AnalyzeOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


52-52: .analyze.AnalyzeStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


53-53: .analyze.AnalyzeSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


56-56: .analyze.AsyncAnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


57-57: .analyze.AnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


58-58: .analyze.SyncAnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


62-62: .speak.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


62-62: .speak.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


63-63: .speak.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


65-65: .speak.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


66-66: .speak.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


68-68: .speak.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


69-69: .speak.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .speak.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .speak.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


75-75: .manage.ManageClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


75-75: .manage.AsyncManageClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


77-77: .manage.ProjectOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


78-78: .manage.KeyOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


79-79: .manage.ScopeOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


80-80: .manage.InviteOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


81-81: .manage.UsageRequestOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


82-82: .manage.UsageSummaryOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


83-83: .manage.UsageFieldsOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


86-86: .manage.Message imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .manage.Project imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


88-88: .manage.ProjectsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


89-89: .manage.MembersResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


90-90: .manage.Key imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


91-91: .manage.KeyResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


92-92: .manage.KeysResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


93-93: .manage.ScopesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


94-94: .manage.InvitesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


95-95: .manage.UsageRequest imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


96-96: .manage.UsageRequestsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


97-97: .manage.UsageSummaryResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


98-98: .manage.UsageFieldsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


99-99: .manage.Balance imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


100-100: .manage.BalancesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


105-105: .selfhosted.OnPremClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


106-106: .selfhosted.AsyncOnPremClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


107-107: .selfhosted.SelfHostedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


108-108: .selfhosted.AsyncSelfHostedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/__init__.py

9-9: logging imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


10-10: .utils.VerboseLogger imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: .utils.NOTICE imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


13-13: .utils.SPAM imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


14-14: .utils.SUCCESS imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


15-15: .utils.VERBOSE imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


16-16: .utils.WARNING imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


17-17: .utils.ERROR imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


18-18: .utils.FATAL imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


19-19: .utils.CRITICAL imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


20-20: .utils.INFO imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


21-21: .utils.DEBUG imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


22-22: .utils.NOTSET imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


25-25: .client.Deepgram imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


25-25: .client.DeepgramClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


26-26: .client.DeepgramClientOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


26-26: .client.ClientOptionsFromEnv imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


27-27: .client.DeepgramApiKeyError imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


27-27: .client.DeepgramModuleError imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


30-30: .client.Listen imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


30-30: .client.Read imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


34-34: .client.TextSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


35-35: .client.BufferSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


36-36: .client.StreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


37-37: .client.FileSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


38-38: .client.UrlSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


39-39: .client.Sentiment imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


43-43: .client.LiveTranscriptionEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


44-44: .client.LiveClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


44-44: .client.AsyncLiveClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


45-45: .client.LiveOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


47-47: .client.OpenResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


48-48: .client.LiveResultResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


49-49: .client.MetadataResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


50-50: .client.SpeechStartedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


51-51: .client.UtteranceEndResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


52-52: .client.CloseResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


53-53: .client.UnhandledResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


54-54: .client.ErrorResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


58-58: .client.PreRecordedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


58-58: .client.AsyncPreRecordedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


60-60: .client.PrerecordedOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


61-61: .client.PreRecordedStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


62-62: .client.PrerecordedSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


65-65: .client.AsyncPrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


66-66: .client.PrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


67-67: .client.SyncPrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


71-71: .client.ReadClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


71-71: .client.AsyncReadClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .client.AnalyzeClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .client.AsyncAnalyzeClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


74-74: .client.AnalyzeOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


75-75: .client.AnalyzeStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


76-76: .client.AnalyzeSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


79-79: .client.AsyncAnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


80-80: .client.AnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


81-81: .client.SyncAnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


85-85: .client.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


85-85: .client.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


86-86: .client.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


86-86: .client.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .client.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .client.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .client.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


88-88: .client.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


89-89: .client.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


92-92: .client.ManageClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


92-92: .client.AsyncManageClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


94-94: .client.ProjectOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


95-95: .client.KeyOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


96-96: .client.ScopeOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


97-97: .client.InviteOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


98-98: .client.UsageRequestOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


99-99: .client.UsageSummaryOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


100-100: .client.UsageFieldsOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


105-105: .client.Message imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


106-106: .client.Project imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


107-107: .client.ProjectsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


108-108: .client.MembersResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


109-109: .client.Key imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


110-110: .client.KeyResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


111-111: .client.KeysResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


112-112: .client.ScopesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


113-113: .client.InvitesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


114-114: .client.UsageRequest imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


115-115: .client.UsageRequestsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


116-116: .client.UsageSummaryResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


117-117: .client.UsageFieldsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


118-118: .client.Balance imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


119-119: .client.BalancesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


124-124: .client.OnPremClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


125-125: .client.AsyncOnPremClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


126-126: .client.SelfHostedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


127-127: .client.AsyncSelfHostedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


131-131: .audio.Microphone imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


133-133: .audio.LOGGING imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


134-134: .audio.CHANNELS imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


135-135: .audio.RATE imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


136-136: .audio.CHUNK imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/client.py

15-15: .clients.TextSource imported but unused (F401)

Remove unused import


16-16: .clients.BufferSource imported but unused (F401)

Remove unused import


17-17: .clients.StreamSource imported but unused (F401)

Remove unused import


18-18: .clients.FileSource imported but unused (F401)

Remove unused import


19-19: .clients.UrlSource imported but unused (F401)

Remove unused import


20-20: .clients.Sentiment imported but unused (F401)

Remove unused import


27-27: .clients.LiveClient imported but unused (F401)

Remove unused import


27-27: .clients.AsyncLiveClient imported but unused (F401)

Remove unused import


29-29: .clients.LiveOptions imported but unused (F401)

Remove unused import


30-30: .clients.LiveTranscriptionEvents imported but unused (F401)

Remove unused import


35-35: .clients.OpenResponse imported but unused (F401)

Remove unused import


36-36: .clients.LiveResultResponse imported but unused (F401)

Remove unused import


37-37: .clients.MetadataResponse imported but unused (F401)

Remove unused import


38-38: .clients.SpeechStartedResponse imported but unused (F401)

Remove unused import


39-39: .clients.UtteranceEndResponse imported but unused (F401)

Remove unused import


40-40: .clients.CloseResponse imported but unused (F401)

Remove unused import


41-41: .clients.ErrorResponse imported but unused (F401)

Remove unused import


42-42: .clients.UnhandledResponse imported but unused (F401)

Remove unused import


47-47: .clients.PreRecordedClient imported but unused (F401)

Remove unused import


48-48: .clients.AsyncPreRecordedClient imported but unused (F401)

Remove unused import


51-51: .clients.PrerecordedOptions imported but unused (F401)

Remove unused import


52-52: .clients.PreRecordedStreamSource imported but unused (F401)

Remove unused import


53-53: .clients.PrerecordedSource imported but unused (F401)

Remove unused import


58-58: .clients.AsyncPrerecordedResponse imported but unused (F401)

Remove unused import


59-59: .clients.PrerecordedResponse imported but unused (F401)

Remove unused import


60-60: .clients.SyncPrerecordedResponse imported but unused (F401)

Remove unused import


64-64: .clients.ReadClient imported but unused (F401)

Remove unused import


64-64: .clients.AsyncReadClient imported but unused (F401)

Remove unused import


65-65: .clients.AnalyzeClient imported but unused (F401)

Remove unused import


65-65: .clients.AsyncAnalyzeClient imported but unused (F401)

Remove unused import


67-67: .clients.AnalyzeOptions imported but unused (F401)

Remove unused import


68-68: .clients.AnalyzeStreamSource imported but unused (F401)

Remove unused import


69-69: .clients.AnalyzeSource imported but unused (F401)

Remove unused import


74-74: .clients.AsyncAnalyzeResponse imported but unused (F401)

Remove unused import


75-75: .clients.AnalyzeResponse imported but unused (F401)

Remove unused import


76-76: .clients.SyncAnalyzeResponse imported but unused (F401)

Remove unused import


80-80: .clients.SpeakClient imported but unused (F401)

Remove unused import


80-80: .clients.AsyncSpeakClient imported but unused (F401)

Remove unused import


81-81: .clients.SpeakStreamClient imported but unused (F401)

Remove unused import


81-81: .clients.AsyncSpeakStreamClient imported but unused (F401)

Remove unused import


82-82: .clients.SpeakOptions imported but unused (F401)

Remove unused import: .clients.SpeakOptions


83-83: .clients.SpeakStreamSource imported but unused (F401)

Remove unused import


83-83: .clients.SpeakSource imported but unused (F401)

Remove unused import


84-84: .clients.SpeakStreamEvents imported but unused (F401)

Remove unused import: .clients.SpeakStreamEvents


87-87: .clients.SpeakResponse imported but unused (F401)

Remove unused import: .clients.SpeakResponse


90-90: .clients.ManageClient imported but unused (F401)

Remove unused import


90-90: .clients.AsyncManageClient imported but unused (F401)

Remove unused import


92-92: .clients.ProjectOptions imported but unused (F401)

Remove unused import


93-93: .clients.KeyOptions imported but unused (F401)

Remove unused import


94-94: .clients.ScopeOptions imported but unused (F401)

Remove unused import


95-95: .clients.InviteOptions imported but unused (F401)

Remove unused import


96-96: .clients.UsageRequestOptions imported but unused (F401)

Remove unused import


97-97: .clients.UsageSummaryOptions imported but unused (F401)

Remove unused import


98-98: .clients.UsageFieldsOptions imported but unused (F401)

Remove unused import


103-103: .clients.Message imported but unused (F401)

Remove unused import


104-104: .clients.Project imported but unused (F401)

Remove unused import


105-105: .clients.ProjectsResponse imported but unused (F401)

Remove unused import


106-106: .clients.MembersResponse imported but unused (F401)

Remove unused import


107-107: .clients.Key imported but unused (F401)

Remove unused import


108-108: .clients.KeyResponse imported but unused (F401)

Remove unused import


109-109: .clients.KeysResponse imported but unused (F401)

Remove unused import


110-110: .clients.ScopesResponse imported but unused (F401)

Remove unused import


111-111: .clients.InvitesResponse imported but unused (F401)

Remove unused import


112-112: .clients.UsageRequest imported but unused (F401)

Remove unused import


113-113: .clients.UsageRequestsResponse imported but unused (F401)

Remove unused import


114-114: .clients.UsageSummaryResponse imported but unused (F401)

Remove unused import


115-115: .clients.UsageFieldsResponse imported but unused (F401)

Remove unused import


116-116: .clients.Balance imported but unused (F401)

Remove unused import


117-117: .clients.BalancesResponse imported but unused (F401)

Remove unused import


122-122: .clients.OnPremClient imported but unused (F401)

Remove unused import


123-123: .clients.AsyncOnPremClient imported but unused (F401)

Remove unused import


124-124: .clients.SelfHostedClient imported but unused (F401)

Remove unused import


125-125: .clients.AsyncSelfHostedClient imported but unused (F401)

Remove unused import


129-129: .options.ClientOptionsFromEnv imported but unused (F401)

Remove unused import: .options.ClientOptionsFromEnv


130-130: .errors.DeepgramApiKeyError imported but unused (F401)

Remove unused import: .errors.DeepgramApiKeyError

deepgram/clients/speak/v1/async_client_stream.py

193-194: Use a single if statement instead of nested if statements (SIM102)

deepgram/clients/live/v1/async_client.py

223-224: Use a single if statement instead of nested if statements (SIM102)

Additional comments not posted (14)
deepgram/clients/speak/v1/__init__.py (1)

6-7: Consider adding new imports to __all__ to clarify their purpose.

The imports of SpeakStreamClient and AsyncSpeakStreamClient are flagged as unused. If these are intended for export, they should be included in the __all__ list. This will clarify their purpose and avoid linting issues.

Tools
Ruff

6-6: .client_stream.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


7-7: .async_client_stream.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/clients/speak/__init__.py (1)

Line range hint 6-16: Consider adding new imports to __all__ to clarify their purpose.

The imports of SpeakStreamClient, AsyncSpeakStreamClient, and SpeakStreamEvents are flagged as unused. If these are intended for export, they should be included in the __all__ list. This will clarify their purpose and avoid linting issues.

Tools
Ruff

5-5: .client.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


7-7: .client.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: .client.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .client.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/clients/__init__.py (1)

68-73: Consider adding new imports to __all__ to clarify their purpose.

The imports of SpeakStreamClient, AsyncSpeakStreamClient, and SpeakStreamEvents are flagged as unused. If these are intended for export, they should be included in the __all__ list. This will clarify their purpose and avoid linting issues.

Tools
Ruff

68-68: .speak.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


69-69: .speak.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .speak.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .speak.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/__init__.py (1)

86-89: Consider adding new imports to __all__ to clarify their purpose.

The imports of SpeakStreamClient, AsyncSpeakStreamClient, and SpeakStreamEvents are flagged as unused. If these are intended for export, they should be included in the __all__ list. This will clarify their purpose and avoid linting issues.

Tools
Ruff

86-86: .client.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


86-86: .client.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .client.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .client.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .client.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


88-88: .client.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


89-89: .client.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

examples/speak-stream/interactive/main.py (1)

24-93: Refactor to use structured logging and improve error handling.

Replace print statements with structured logging for better consistency and maintainability. Improve error handling by catching specific exceptions and using more descriptive error messages.

import logging

+ logger = logging.getLogger(__name__)

- print(f"\n\n{open}\n\n")
+ logger.info(f"Open: {open}")

- print("Failed to start connection")
+ logger.error("Failed to start connection")
deepgram/client.py (2)

241-245: Approval for speakstream property addition.
The implementation for accessing SpeakStreamClient through speakstream property is consistent with the existing architecture of the client.


247-252: Approval for asyncspeakstream property addition.
The addition of the asyncspeakstream property to access AsyncSpeakStreamClient aligns well with the SDK's architecture and provides a clear asynchronous alternative.

deepgram/clients/speak/v1/client_stream.py (3)

60-81: Constructor review for SpeakStreamClient.

The constructor properly initializes all necessary instance attributes and sets up logging. The check for config being None is consistent with the previous discussions and learnings indicating that the config object is always created before being passed to the constructor.


398-450: Review of send method in SpeakStreamClient.

The method correctly handles thread safety with a lock and provides comprehensive error handling. The logging level might be adjusted to provide more appropriate feedback in production environments.

- self._logger.spam("SpeakStreamClient.send ENTER")
+ self._logger.debug("SpeakStreamClient.send ENTER")

459-486: Review of flush method in SpeakStreamClient.

The method effectively uses the send method to flush the WebSocket buffer and handles potential errors well.

deepgram/clients/speak/v1/async_client_stream.py (2)

197-226: Good management of tasks in the _emit method.

The method correctly creates tasks for each event handler, waits for them to complete, and clears the list to prevent memory leaks.


554-596: Ensure proper cleanup in the _signal_exit method.

The method should ensure that all tasks are completed and the WebSocket is closed properly to avoid resource leaks.

deepgram/clients/live/v1/async_client.py (2)

242-248: Efficient handling of asynchronous tasks.

Creating and awaiting tasks for each event handler ensures that all handlers are executed in parallel, and using asyncio.gather with return_exceptions=True is a good practice to handle exceptions gracefully.


386-386: Proper handling of specific WebSocket error codes.

Handling specific WebSocket error codes (1000, 1001) gracefully is a good practice. Consider adding a comment or documentation to explain why these specific codes are treated differently, enhancing maintainability.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 18

Outside diff range and nitpick comments (2)
deepgram/clients/speak/__init__.py (1)

Line range hint 6-16: Consolidate imports from the same module for clarity.

Multiple imports from .client can be consolidated to improve clarity and maintainability.

- from .client import SpeakClient
- from .client import SpeakStreamClient, AsyncSpeakStreamClient
- from .client import AsyncSpeakClient
- from .client import SpeakOptions
- from .client import SpeakResponse
- from .client import (
-     FileSource,
-     SpeakStreamSource,
-     SpeakSource,
- )
+ from .client import (
+     SpeakClient,
+     SpeakStreamClient,
+     AsyncSpeakClient,
+     SpeakOptions,
+     SpeakResponse,
+     FileSource,
+     SpeakStreamSource,
+     SpeakSource
+ )
Tools
Ruff

5-5: .client.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


7-7: .client.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: .client.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .client.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

examples/speak-stream/interactive/main.py (1)

74-79: Good use of locking to prevent race conditions.

The use of threading.Lock in the send_tts_text function is appropriate to ensure that multiple threads do not cause race conditions when sending text to speech data. However, consider if the threading model can be simplified or improved to avoid excessive thread management complexity.

Review the overall threading model to ensure it aligns with best practices and consider alternatives like asynchronous programming if applicable.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 234f05c and 3b6c941.

Files selected for processing (14)
  • deepgram/init.py (1 hunks)
  • deepgram/client.py (5 hunks)
  • deepgram/clients/init.py (1 hunks)
  • deepgram/clients/live/v1/async_client.py (3 hunks)
  • deepgram/clients/speak/init.py (2 hunks)
  • deepgram/clients/speak/client.py (2 hunks)
  • deepgram/clients/speak/enums.py (1 hunks)
  • deepgram/clients/speak/errors.py (1 hunks)
  • deepgram/clients/speak/v1/init.py (1 hunks)
  • deepgram/clients/speak/v1/async_client_stream.py (1 hunks)
  • deepgram/clients/speak/v1/client_stream.py (1 hunks)
  • deepgram/clients/speak/v1/response.py (1 hunks)
  • examples/speak-stream/async-interactive/main.py (1 hunks)
  • examples/speak-stream/interactive/main.py (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • deepgram/clients/speak/client.py
  • deepgram/clients/speak/enums.py
  • deepgram/clients/speak/errors.py
Additional context used
Learnings (2)
deepgram/clients/speak/v1/client_stream.py (2)
User: dvonthenen
PR: deepgram/deepgram-python-sdk#424
File: deepgram/clients/speak/v1/client_stream.py:59-79
Timestamp: 2024-06-25T15:26:40.699Z
Learning: The `config` object is always created before being passed to the `SpeakStreamClient` constructor, and should not be `null`.
User: dvonthenen
PR: deepgram/deepgram-python-sdk#424
File: deepgram/clients/speak/v1/async_client_stream.py:55-74
Timestamp: 2024-06-25T15:18:16.852Z
Learning: The `config` parameter in the `AsyncSpeakStreamClient` constructor should not be optional and must be enforced at the type level.
deepgram/clients/speak/v1/async_client_stream.py (2)
User: dvonthenen
PR: deepgram/deepgram-python-sdk#424
File: deepgram/clients/speak/v1/async_client_stream.py:55-74
Timestamp: 2024-06-25T15:18:16.852Z
Learning: The `config` parameter in the `AsyncSpeakStreamClient` constructor should not be optional and must be enforced at the type level.
User: dvonthenen
PR: deepgram/deepgram-python-sdk#424
File: deepgram/clients/speak/v1/client_stream.py:59-79
Timestamp: 2024-06-25T15:26:40.699Z
Learning: The `config` object is always created before being passed to the `SpeakStreamClient` constructor, and should not be `null`.
Ruff
deepgram/clients/speak/v1/__init__.py

5-5: .client.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client_stream.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


7-7: .async_client_stream.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: .async_client.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .options.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .options.FileSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .options.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .options.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


10-10: .response.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: ....options.DeepgramClientOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: ....options.ClientOptionsFromEnv imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/clients/speak/__init__.py

5-5: .client.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: .client.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


7-7: .client.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: .client.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .client.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


11-11: .client.FileSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: .client.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


13-13: .client.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


16-16: .enums.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


17-17: ...options.DeepgramClientOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


17-17: ...options.ClientOptionsFromEnv imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/clients/__init__.py

7-7: .common.TextSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: .common.BufferSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: .common.StreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


10-10: .common.FileSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


11-11: .common.UrlSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: .common.Sentiment imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


16-16: .listen.Listen imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


17-17: .read.Read imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


20-20: .live.LiveClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


20-20: .live.AsyncLiveClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


21-21: .live.LiveOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


22-22: .live.LiveTranscriptionEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


24-24: .live.OpenResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


25-25: .live.LiveResultResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


26-26: .live.MetadataResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


27-27: .live.SpeechStartedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


28-28: .live.UtteranceEndResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


29-29: .live.CloseResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


30-30: .live.ErrorResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


31-31: .live.UnhandledResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


35-35: .prerecorded.PreRecordedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


35-35: .prerecorded.AsyncPreRecordedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


36-36: .prerecorded.PrerecordedOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


38-38: .prerecorded.PreRecordedStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


39-39: .prerecorded.PrerecordedSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


42-42: .prerecorded.AsyncPrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


43-43: .prerecorded.PrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


44-44: .prerecorded.SyncPrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


48-48: .analyze.ReadClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


48-48: .analyze.AsyncReadClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


49-49: .analyze.AnalyzeClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


49-49: .analyze.AsyncAnalyzeClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


50-50: .analyze.AnalyzeOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


52-52: .analyze.AnalyzeStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


53-53: .analyze.AnalyzeSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


56-56: .analyze.AsyncAnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


57-57: .analyze.AnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


58-58: .analyze.SyncAnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


62-62: .speak.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


62-62: .speak.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


63-63: .speak.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


65-65: .speak.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


66-66: .speak.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


68-68: .speak.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


69-69: .speak.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .speak.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .speak.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


75-75: .manage.ManageClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


75-75: .manage.AsyncManageClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


77-77: .manage.ProjectOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


78-78: .manage.KeyOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


79-79: .manage.ScopeOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


80-80: .manage.InviteOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


81-81: .manage.UsageRequestOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


82-82: .manage.UsageSummaryOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


83-83: .manage.UsageFieldsOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


86-86: .manage.Message imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .manage.Project imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


88-88: .manage.ProjectsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


89-89: .manage.MembersResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


90-90: .manage.Key imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


91-91: .manage.KeyResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


92-92: .manage.KeysResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


93-93: .manage.ScopesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


94-94: .manage.InvitesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


95-95: .manage.UsageRequest imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


96-96: .manage.UsageRequestsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


97-97: .manage.UsageSummaryResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


98-98: .manage.UsageFieldsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


99-99: .manage.Balance imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


100-100: .manage.BalancesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


105-105: .selfhosted.OnPremClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


106-106: .selfhosted.AsyncOnPremClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


107-107: .selfhosted.SelfHostedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


108-108: .selfhosted.AsyncSelfHostedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/__init__.py

9-9: logging imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


10-10: .utils.VerboseLogger imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: .utils.NOTICE imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


13-13: .utils.SPAM imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


14-14: .utils.SUCCESS imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


15-15: .utils.VERBOSE imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


16-16: .utils.WARNING imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


17-17: .utils.ERROR imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


18-18: .utils.FATAL imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


19-19: .utils.CRITICAL imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


20-20: .utils.INFO imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


21-21: .utils.DEBUG imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


22-22: .utils.NOTSET imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


25-25: .client.Deepgram imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


25-25: .client.DeepgramClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


26-26: .client.DeepgramClientOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


26-26: .client.ClientOptionsFromEnv imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


27-27: .client.DeepgramApiKeyError imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


27-27: .client.DeepgramModuleError imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


30-30: .client.Listen imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


30-30: .client.Read imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


34-34: .client.TextSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


35-35: .client.BufferSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


36-36: .client.StreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


37-37: .client.FileSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


38-38: .client.UrlSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


39-39: .client.Sentiment imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


43-43: .client.LiveTranscriptionEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


44-44: .client.LiveClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


44-44: .client.AsyncLiveClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


45-45: .client.LiveOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


47-47: .client.OpenResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


48-48: .client.LiveResultResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


49-49: .client.MetadataResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


50-50: .client.SpeechStartedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


51-51: .client.UtteranceEndResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


52-52: .client.CloseResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


53-53: .client.UnhandledResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


54-54: .client.ErrorResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


58-58: .client.PreRecordedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


58-58: .client.AsyncPreRecordedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


60-60: .client.PrerecordedOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


61-61: .client.PreRecordedStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


62-62: .client.PrerecordedSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


65-65: .client.AsyncPrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


66-66: .client.PrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


67-67: .client.SyncPrerecordedResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


71-71: .client.ReadClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


71-71: .client.AsyncReadClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .client.AnalyzeClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .client.AsyncAnalyzeClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


74-74: .client.AnalyzeOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


75-75: .client.AnalyzeStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


76-76: .client.AnalyzeSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


79-79: .client.AsyncAnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


80-80: .client.AnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


81-81: .client.SyncAnalyzeResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


85-85: .client.SpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


85-85: .client.AsyncSpeakClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


86-86: .client.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


86-86: .client.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .client.SpeakOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .client.SpeakStreamSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


87-87: .client.SpeakSource imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


88-88: .client.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


89-89: .client.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


92-92: .client.ManageClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


92-92: .client.AsyncManageClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


94-94: .client.ProjectOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


95-95: .client.KeyOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


96-96: .client.ScopeOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


97-97: .client.InviteOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


98-98: .client.UsageRequestOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


99-99: .client.UsageSummaryOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


100-100: .client.UsageFieldsOptions imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


105-105: .client.Message imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


106-106: .client.Project imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


107-107: .client.ProjectsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


108-108: .client.MembersResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


109-109: .client.Key imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


110-110: .client.KeyResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


111-111: .client.KeysResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


112-112: .client.ScopesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


113-113: .client.InvitesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


114-114: .client.UsageRequest imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


115-115: .client.UsageRequestsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


116-116: .client.UsageSummaryResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


117-117: .client.UsageFieldsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


118-118: .client.Balance imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


119-119: .client.BalancesResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


124-124: .client.OnPremClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


125-125: .client.AsyncOnPremClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


126-126: .client.SelfHostedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


127-127: .client.AsyncSelfHostedClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


131-131: .audio.Microphone imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


133-133: .audio.LOGGING imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


134-134: .audio.CHANNELS imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


135-135: .audio.RATE imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


136-136: .audio.CHUNK imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

examples/speak-stream/interactive/main.py

8-8: deepgram.utils.verboselogs imported but unused (F401)

Remove unused import: deepgram.utils.verboselogs


12-12: deepgram.DeepgramClientOptions imported but unused (F401)

Remove unused import: deepgram.DeepgramClientOptions

examples/speak-stream/async-interactive/main.py

4-4: deepgram.utils.verboselogs imported but unused (F401)

Remove unused import: deepgram.utils.verboselogs


7-7: deepgram.DeepgramClientOptions imported but unused (F401)

Remove unused import: deepgram.DeepgramClientOptions

deepgram/client.py

15-15: .clients.TextSource imported but unused (F401)

Remove unused import


16-16: .clients.BufferSource imported but unused (F401)

Remove unused import


17-17: .clients.StreamSource imported but unused (F401)

Remove unused import


18-18: .clients.FileSource imported but unused (F401)

Remove unused import


19-19: .clients.UrlSource imported but unused (F401)

Remove unused import


20-20: .clients.Sentiment imported but unused (F401)

Remove unused import


27-27: .clients.LiveClient imported but unused (F401)

Remove unused import


27-27: .clients.AsyncLiveClient imported but unused (F401)

Remove unused import


29-29: .clients.LiveOptions imported but unused (F401)

Remove unused import


30-30: .clients.LiveTranscriptionEvents imported but unused (F401)

Remove unused import


35-35: .clients.OpenResponse imported but unused (F401)

Remove unused import


36-36: .clients.LiveResultResponse imported but unused (F401)

Remove unused import


37-37: .clients.MetadataResponse imported but unused (F401)

Remove unused import


38-38: .clients.SpeechStartedResponse imported but unused (F401)

Remove unused import


39-39: .clients.UtteranceEndResponse imported but unused (F401)

Remove unused import


40-40: .clients.CloseResponse imported but unused (F401)

Remove unused import


41-41: .clients.ErrorResponse imported but unused (F401)

Remove unused import


42-42: .clients.UnhandledResponse imported but unused (F401)

Remove unused import


47-47: .clients.PreRecordedClient imported but unused (F401)

Remove unused import


48-48: .clients.AsyncPreRecordedClient imported but unused (F401)

Remove unused import


51-51: .clients.PrerecordedOptions imported but unused (F401)

Remove unused import


52-52: .clients.PreRecordedStreamSource imported but unused (F401)

Remove unused import


53-53: .clients.PrerecordedSource imported but unused (F401)

Remove unused import


58-58: .clients.AsyncPrerecordedResponse imported but unused (F401)

Remove unused import


59-59: .clients.PrerecordedResponse imported but unused (F401)

Remove unused import


60-60: .clients.SyncPrerecordedResponse imported but unused (F401)

Remove unused import


64-64: .clients.ReadClient imported but unused (F401)

Remove unused import


64-64: .clients.AsyncReadClient imported but unused (F401)

Remove unused import


65-65: .clients.AnalyzeClient imported but unused (F401)

Remove unused import


65-65: .clients.AsyncAnalyzeClient imported but unused (F401)

Remove unused import


67-67: .clients.AnalyzeOptions imported but unused (F401)

Remove unused import


68-68: .clients.AnalyzeStreamSource imported but unused (F401)

Remove unused import


69-69: .clients.AnalyzeSource imported but unused (F401)

Remove unused import


74-74: .clients.AsyncAnalyzeResponse imported but unused (F401)

Remove unused import


75-75: .clients.AnalyzeResponse imported but unused (F401)

Remove unused import


76-76: .clients.SyncAnalyzeResponse imported but unused (F401)

Remove unused import


80-80: .clients.SpeakClient imported but unused (F401)

Remove unused import


80-80: .clients.AsyncSpeakClient imported but unused (F401)

Remove unused import


81-81: .clients.SpeakStreamClient imported but unused (F401)

Remove unused import


81-81: .clients.AsyncSpeakStreamClient imported but unused (F401)

Remove unused import


82-82: .clients.SpeakOptions imported but unused (F401)

Remove unused import: .clients.SpeakOptions


83-83: .clients.SpeakStreamSource imported but unused (F401)

Remove unused import


83-83: .clients.SpeakSource imported but unused (F401)

Remove unused import


84-84: .clients.SpeakStreamEvents imported but unused (F401)

Remove unused import: .clients.SpeakStreamEvents


87-87: .clients.SpeakResponse imported but unused (F401)

Remove unused import: .clients.SpeakResponse


90-90: .clients.ManageClient imported but unused (F401)

Remove unused import


90-90: .clients.AsyncManageClient imported but unused (F401)

Remove unused import


92-92: .clients.ProjectOptions imported but unused (F401)

Remove unused import


93-93: .clients.KeyOptions imported but unused (F401)

Remove unused import


94-94: .clients.ScopeOptions imported but unused (F401)

Remove unused import


95-95: .clients.InviteOptions imported but unused (F401)

Remove unused import


96-96: .clients.UsageRequestOptions imported but unused (F401)

Remove unused import


97-97: .clients.UsageSummaryOptions imported but unused (F401)

Remove unused import


98-98: .clients.UsageFieldsOptions imported but unused (F401)

Remove unused import


103-103: .clients.Message imported but unused (F401)

Remove unused import


104-104: .clients.Project imported but unused (F401)

Remove unused import


105-105: .clients.ProjectsResponse imported but unused (F401)

Remove unused import


106-106: .clients.MembersResponse imported but unused (F401)

Remove unused import


107-107: .clients.Key imported but unused (F401)

Remove unused import


108-108: .clients.KeyResponse imported but unused (F401)

Remove unused import


109-109: .clients.KeysResponse imported but unused (F401)

Remove unused import


110-110: .clients.ScopesResponse imported but unused (F401)

Remove unused import


111-111: .clients.InvitesResponse imported but unused (F401)

Remove unused import


112-112: .clients.UsageRequest imported but unused (F401)

Remove unused import


113-113: .clients.UsageRequestsResponse imported but unused (F401)

Remove unused import


114-114: .clients.UsageSummaryResponse imported but unused (F401)

Remove unused import


115-115: .clients.UsageFieldsResponse imported but unused (F401)

Remove unused import


116-116: .clients.Balance imported but unused (F401)

Remove unused import


117-117: .clients.BalancesResponse imported but unused (F401)

Remove unused import


122-122: .clients.OnPremClient imported but unused (F401)

Remove unused import


123-123: .clients.AsyncOnPremClient imported but unused (F401)

Remove unused import


124-124: .clients.SelfHostedClient imported but unused (F401)

Remove unused import


125-125: .clients.AsyncSelfHostedClient imported but unused (F401)

Remove unused import


129-129: .options.ClientOptionsFromEnv imported but unused (F401)

Remove unused import: .options.ClientOptionsFromEnv


130-130: .errors.DeepgramApiKeyError imported but unused (F401)

Remove unused import: .errors.DeepgramApiKeyError

deepgram/clients/speak/v1/async_client_stream.py

193-194: Use a single if statement instead of nested if statements (SIM102)

deepgram/clients/live/v1/async_client.py

223-224: Use a single if statement instead of nested if statements (SIM102)

Additional comments not posted (12)
deepgram/clients/speak/v1/__init__.py (1)

6-7: Imports are well-organized but consider usage documentation.

The imports are correctly structured, but it would be beneficial to include comments or documentation on how these imports are intended to be used, especially since they are designed for external exposure.

Tools
Ruff

6-6: .client_stream.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


7-7: .async_client_stream.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/clients/speak/__init__.py (1)

16-16: Consider documenting the use of SpeakStreamEvents.

SpeakStreamEvents is imported but not documented within this file. Adding usage examples or a brief description can help developers understand its purpose better.

Tools
Ruff

16-16: .enums.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/clients/__init__.py (1)

68-73: Imports are well-organized but consider usage documentation.

The imports are correctly structured, but it would be beneficial to include comments or documentation on how these imports are intended to be used, especially since they are designed for external exposure.

Tools
Ruff

68-68: .speak.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


69-69: .speak.SpeakResponse imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .speak.SpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


72-72: .speak.AsyncSpeakStreamClient imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/__init__.py (1)

89-89: Consider documenting the use of SpeakStreamEvents.

SpeakStreamEvents is imported but not documented within this file. Adding usage examples or a brief description can help developers understand its purpose better.

Tools
Ruff

89-89: .client.SpeakStreamEvents imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

deepgram/client.py (1)

241-253: Implement properties for SpeakStream functionality correctly.

The properties speakstream and asyncspeakstream are implemented to return instances of SpeakStreamClient and AsyncSpeakStreamClient. Ensure these are correctly integrated and tested.

deepgram/clients/speak/v1/async_client_stream.py (5)

197-225: Good implementation of the _emit method.

The method effectively manages asynchronous tasks and ensures they are awaited and cleared, which is crucial for preventing memory leaks and ensuring all tasks complete before proceeding.


421-473: Consider reducing logging verbosity in the send method.

Excessive logging, especially at spam levels, can impact performance. Consider reducing the verbosity to debug or info level.

- self._logger.spam("AsyncSpeakStreamClient.send ENTER")
+ self._logger.debug("AsyncSpeakStreamClient.send ENTER")
- self._logger.spam("AsyncSpeakStreamClient.send LEAVE")
+ self._logger.debug("AsyncSpeakStreamClient.send LEAVE")

477-503: Good implementation of the flush method.

The method correctly handles the state of the WebSocket and ensures that operations are only attempted when the socket is initialized.


506-553: Well-implemented finish method.

The method effectively manages task cancellation and handles exceptions appropriately, ensuring a graceful shutdown of the WebSocket connection.


554-596: Effective management of WebSocket closure in _signal_exit.

The method correctly signals the exit event and manages the WebSocket closure, including handling various exceptions that might occur during the process.

deepgram/clients/live/v1/async_client.py (2)

242-248: Enhance event emission with concurrent task handling.

Creating tasks for each event handler and using asyncio.gather to wait for all tasks to complete allows for efficient concurrent processing. Ensure that exceptions in tasks are logged or handled appropriately to avoid silent failures.


386-386: Improve graceful exit handling for WebSocket closures.

Handling specific WebSocket close codes (1000, 1001) gracefully is a good practice. Consider reviewing if other close codes should also be handled similarly based on the application's requirements.

deepgram/clients/live/v1/async_client.py Show resolved Hide resolved
deepgram/__init__.py Show resolved Hide resolved
deepgram/clients/speak/v1/client_stream.py Show resolved Hide resolved
@dvonthenen
Copy link
Contributor

It looks like the blackformatter doesnt error the unit tests out. Will fix in this in a subsequent PR.

Copy link
Contributor

@dvonthenen dvonthenen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me!

@dvonthenen dvonthenen merged commit df78073 into main Jun 27, 2024
3 checks passed
@dvonthenen dvonthenen deleted the sr/TTS-streaming-API branch June 27, 2024 00:09
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