Skip to content

Filter silence#1200

Merged
yujonglee merged 6 commits intomainfrom
filter-silence
Jul 24, 2025
Merged

Filter silence#1200
yujonglee merged 6 commits intomainfrom
filter-silence

Conversation

@yujonglee
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 24, 2025

📝 Walkthrough

Walkthrough

The changes remove the local "hypr-vad" crate and its codebase, replacing it with the external "silero-rs" VAD library. All chunking and predictor logic in the chunker crate is refactored to use the new VAD-based chunking approach. The plugin and server code are updated to use VAD chunking streams, with error handling and stream processing logic adapted accordingly. All code and configuration for the previous VAD implementation are deleted.

Changes

File(s) / Path(s) Change Summary
Cargo.toml, crates/chunker/Cargo.toml Remove local "hypr-vad" and related dependencies; add "silero-rs" and update dependency lists and features.
crates/chunker/src/error.rs Refactor error enum: remove hypr_vad error variant, add new VAD error variants, remove custom serialization.
crates/chunker/src/lib.rs Replace chunking/predictor logic with VAD-based chunking using silero_rs; add new stream and trait structures.
crates/chunker/src/predictor.rs, crates/chunker/src/stream.rs Delete old predictor trait, RMS/Silero predictors, and previous chunk stream logic.
crates/vad/* Delete entire local vad crate: Cargo.toml, error.rs, lib.rs.
plugins/local-stt/Cargo.toml Remove "hypr-chunker/load-dynamic" from plugin features.
plugins/local-stt/src/server.rs Refactor to use VAD-based chunking, add process_vad_stream, update stream processing and error handling.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant WebSocketServer
    participant Chunker (VAD)
    participant SileroVAD
    participant Transcriber

    Client->>WebSocketServer: Send audio stream
    WebSocketServer->>Chunker (VAD): Pass audio stream
    Chunker (VAD)->>SileroVAD: Process audio chunks for speech detection
    SileroVAD-->>Chunker (VAD): Speech segment boundaries
    Chunker (VAD)-->>WebSocketServer: Yield detected speech chunks
    WebSocketServer->>Transcriber: Forward speech chunks
    Transcriber-->>WebSocketServer: Transcription results
    WebSocketServer-->>Client: Send transcription
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Note

⚡️ Unit Test Generation - Beta

CodeRabbit's unit test generation is now available in Beta! Automatically generate comprehensive unit tests for your code changes, ensuring better test coverage and catching edge cases you might miss. Our AI analyzes your code structure and creates tests that follow best practices and your project's testing patterns. Learn more here, or just try it under ✨ Finishing Touches.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch filter-silence

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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

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.

This was linked to issues Jul 24, 2025
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: 1

🧹 Nitpick comments (3)
plugins/local-stt/src/server.rs (1)

210-210: Verify impact of lowered confidence threshold.

The confidence threshold was lowered from 0.2 to 0.1, making transcription more permissive. Ensure this doesn't introduce too many low-quality transcriptions.

Consider making this threshold configurable or documenting the rationale for the change.

crates/chunker/src/lib.rs (2)

61-63: Optimize chunk creation by avoiding unnecessary allocation.

The current implementation creates a new Vec and then extends it. Since we know the exact size, we can directly take ownership of the drained elements.

-        let mut chunk = Vec::with_capacity(this.chunk_samples);
-        chunk.extend(this.buffer.drain(..this.chunk_samples));
+        let chunk: Vec<f32> = this.buffer.drain(..this.chunk_samples).collect();

93-94: Improve comment to explain the 30ms chunk duration choice.

The current comment only provides a link without explaining why 30ms is used.

-        // https://github.com/emotechlab/silero-rs/blob/26a6460/src/lib.rs#L775
+        // Use 30ms chunks as recommended by silero-rs for optimal VAD performance
         let chunk_duration = Duration::from_millis(30);
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a634777 and c1d704a.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • Cargo.toml (1 hunks)
  • crates/chunker/Cargo.toml (1 hunks)
  • crates/chunker/src/error.rs (1 hunks)
  • crates/chunker/src/lib.rs (1 hunks)
  • crates/chunker/src/predictor.rs (0 hunks)
  • crates/chunker/src/stream.rs (0 hunks)
  • crates/vad/Cargo.toml (0 hunks)
  • crates/vad/src/error.rs (0 hunks)
  • crates/vad/src/lib.rs (0 hunks)
  • plugins/local-stt/Cargo.toml (1 hunks)
  • plugins/local-stt/src/server.rs (5 hunks)
💤 Files with no reviewable changes (5)
  • crates/vad/Cargo.toml
  • crates/vad/src/error.rs
  • crates/chunker/src/stream.rs
  • crates/chunker/src/predictor.rs
  • crates/vad/src/lib.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit Configuration File

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • plugins/local-stt/src/server.rs
  • crates/chunker/src/lib.rs
  • crates/chunker/src/error.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: ci (macos, macos-latest)
  • GitHub Check: ci (windows, windows-latest)
  • GitHub Check: ci
🔇 Additional comments (9)
plugins/local-stt/Cargo.toml (1)

24-24: LGTM - Dependency removal aligns with VAD refactor.

The removal of "hypr-chunker/load-dynamic" from the load-dynamic feature is consistent with the migration from the internal hypr-vad crate to the external silero-rs library.

Cargo.toml (1)

195-195: External silero-rs dependency is trustworthy and actively maintained

The silero-rs repository is not archived, was recently updated (2025-07-01), and has a healthy star count, so pinning it at commit 26a6460 is safe.

crates/chunker/Cargo.toml (1)

11-19: LGTM - Dependencies align with VAD refactoring.

The new dependencies (serde, thiserror, silero-rs, tracing) properly support the migration from the internal hypr-vad implementation to the external silero-rs VAD library.

crates/chunker/src/error.rs (1)

3-6: LGTM - Error variants properly support new VAD implementation.

The new error variants VadSessionCreationFailed and VadProcessingFailed appropriately handle errors from the silero-rs VAD library with clear, descriptive messages.

plugins/local-stt/src/server.rs (4)

20-20: LGTM - VadExt trait import supports new chunking approach.

The import of VadExt trait aligns with the migration to VAD-based chunking using the silero-rs library.


151-157: LGTM - Single channel VAD chunking implementation.

The replacement of RMS-based chunking with VAD-based chunking using vad_chunks() and the process_vad_stream helper is well-structured and maintains the same transcription flow.


169-177: LGTM - Dual channel VAD chunking implementation.

Both mic and speaker channels now use VAD-based chunking consistently, with proper source labeling for downstream processing.


253-282: LGTM - Well-designed VAD stream processing helper.

The process_vad_stream function properly handles error scenarios by terminating the stream on VAD errors and converts chunks to the expected format with source metadata. The error handling approach using take_while and filter_map is appropriate.

crates/chunker/src/lib.rs (1)

1-14: LGTM!

All imports are properly used throughout the file.

@yujonglee yujonglee mentioned this pull request Jul 24, 2025
@yujonglee yujonglee merged commit 5142791 into main Jul 24, 2025
7 checks passed
@yujonglee yujonglee deleted the filter-silence branch July 24, 2025 00:46
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.

Filter silence from transcript Silero based audio chunker

1 participant