Skip to content

Disable all external triggers including realtime integration, realtime…#1178

Merged
beastoin merged 1 commit intomainfrom
wuaif_external_triggers
Oct 26, 2024
Merged

Disable all external triggers including realtime integration, realtime…#1178
beastoin merged 1 commit intomainfrom
wuaif_external_triggers

Conversation

@beastoin
Copy link
Copy Markdown
Collaborator

@beastoin beastoin commented Oct 26, 2024

… transcript, realtime bytes audio due to bad performance, direct affect to core features - live transcript socket

Summary by CodeRabbit

  • New Features

    • Introduced real-time audio processing capabilities with a focus on stability and performance.
  • Bug Fixes

    • Enhanced error handling for audio data reception and processing.
  • Refactor

    • Improved logic for managing audio processing tasks and memory creation.
  • Chores

    • Temporarily disabled real-time integrations and webhook calls to address performance issues.

… transcript, realtime bytes audio due to bad performance, direct affect to core features - live transcript socket
@beastoin beastoin marked this pull request as ready for review October 26, 2024 01:47
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 26, 2024

Walkthrough

The changes in this pull request primarily affect the backend/routers/transcribe_v2.py file, focusing on audio data handling and real-time processing features. Key modifications include the temporary disabling of real-time integrations and webhook calls in the stream_transcript function, as well as adjustments to the receive_audio function's audiobuffer functionality. The logic for managing audio processing tasks has been refined with a cancellation mechanism for ongoing tasks. Additionally, error handling has been improved throughout the file, reflecting a cautious approach to audio data management within the WebSocket context.

Changes

File Path Change Summary
backend/routers/transcribe_v2.py - Commented out real-time integrations and webhook calls in stream_transcript.
- Commented out audiobuffer functionality in receive_audio.
- Added cancellation mechanism in create_memory_on_segment_received_task.
- Streamlined socket management for deepgram service.
- Enhanced error handling in receive_audio.
- Updated function signature for websocket_endpoint (no changes to the signature itself).

Possibly related PRs

  • Fix mic records #1041: This PR modifies the receive_audio function in backend/routers/transcribe_v2.py to replace inline speech detection logic with a new utility function, which is directly related to the audio data handling changes in the main PR.
  • Disable comment on developer webhook due to the log spamming, feel fr… #1088: This PR enhances the websocket_endpoint function and improves error handling in backend/routers/transcribe_v2.py, which aligns with the main PR's focus on refining audio processing and error management.

🐇 In the realm of sound, we take a pause,
To smooth the waves, and fix the flaws.
With websockets dancing, we tread with care,
Commented out calls, we handle with flair.
A hop and a skip, we refine our way,
For clearer echoes in the light of day! 🌟


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

Copy link
Copy Markdown
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: 1

🧹 Outside diff range and nitpick comments (2)
backend/routers/transcribe_v2.py (2)

332-332: Clean up unused audio buffer code.

The audio buffer initialization and extension are commented out but the variable is still referenced in the webhook section. Since this feature is being disabled, consider removing all related code for better maintainability.

-        #audiobuffer = bytearray()
         try:
             while websocket_active:
                 data = await websocket.receive_bytes()
-                #audiobuffer.extend(data)

Also applies to: 345-345


369-373: Improve webhook implementation and consider performance optimizations.

The developer webhook is disabled due to performance issues. When re-enabling this feature, consider:

  1. Moving the webhook call to a background task
  2. Implementing rate limiting
  3. Adding buffer size limits
  4. Using feature flags instead of commented code

Example implementation with improvements:

-                # Thinh's comment: Temporarily disabled due to bad performance
-                #if audio_bytes_webhook_delay_seconds and len(
-                #        audiobuffer) > sample_rate * audio_bytes_webhook_delay_seconds * 2:
-                #    asyncio.create_task(send_audio_bytes_developer_webhook(uid, sample_rate, audiobuffer.copy()))
-                #    audiobuffer = bytearray()
+                if os.getenv('ENABLE_AUDIO_WEBHOOK', 'false').lower() == 'true':
+                    current_time = time.time()
+                    if (
+                        audio_bytes_webhook_delay_seconds 
+                        and len(audiobuffer) > sample_rate * audio_bytes_webhook_delay_seconds * 2
+                        and current_time - last_webhook_time >= MIN_WEBHOOK_INTERVAL
+                    ):
+                        last_webhook_time = current_time
+                        if len(audiobuffer) > MAX_BUFFER_SIZE:
+                            audiobuffer = audiobuffer[-MAX_BUFFER_SIZE:]
+                        asyncio.create_task(send_audio_bytes_developer_webhook(uid, sample_rate, audiobuffer.copy()))
+                        audiobuffer = bytearray()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e5ee123 and deae097.

📒 Files selected for processing (1)
  • backend/routers/transcribe_v2.py (4 hunks)

Comment on lines +265 to +268
# Thinh's comment: Temporarily disabled due to bad performance
# realtime plugins + realtime webhook
asyncio.run_coroutine_threadsafe(trigger_realtime_integrations(uid, segments), loop)
asyncio.run_coroutine_threadsafe(realtime_transcript_webhook(uid, segments), loop)
#asyncio.run_coroutine_threadsafe(trigger_realtime_integrations(uid, segments), loop)
#asyncio.run_coroutine_threadsafe(realtime_transcript_webhook(uid, segments), loop)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using feature flags instead of commenting out code.

While disabling these features aligns with the PR objectives to address performance issues, using comments to disable code is not ideal for temporary changes. Consider implementing feature flags or configuration settings to control these integrations.

Example implementation using environment variables:

-        # Thinh's comment: Temporarily disabled due to bad performance
-        # realtime plugins + realtime webhook
-        #asyncio.run_coroutine_threadsafe(trigger_realtime_integrations(uid, segments), loop)
-        #asyncio.run_coroutine_threadsafe(realtime_transcript_webhook(uid, segments), loop)
+        if os.getenv('ENABLE_REALTIME_INTEGRATIONS', 'false').lower() == 'true':
+            asyncio.run_coroutine_threadsafe(trigger_realtime_integrations(uid, segments), loop)
+            asyncio.run_coroutine_threadsafe(realtime_transcript_webhook(uid, segments), loop)

Committable suggestion was skipped due to low confidence.

@beastoin beastoin merged commit 72194da into main Oct 26, 2024
@beastoin beastoin deleted the wuaif_external_triggers branch October 26, 2024 01:57
@beastoin beastoin changed the title Disable all external triggers including reatime integration, realtime… Disable all external triggers including realtime integration, realtime… Oct 26, 2024
This was referenced Nov 7, 2024
Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
BasedHardware#1178)

… transcript, realtime bytes audio due to bad performance, direct affect
to core features - live transcript socket

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced real-time audio processing capabilities with a focus on
stability and performance.
  
- **Bug Fixes**
	- Enhanced error handling for audio data reception and processing.

- **Refactor**
- Improved logic for managing audio processing tasks and memory
creation.

- **Chores**
- Temporarily disabled real-time integrations and webhook calls to
address performance issues.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

1 participant