Skip to content

Release Rust package for offline/online speech denoiser - #3328

Merged
csukuangfj merged 3 commits into
k2-fsa:masterfrom
csukuangfj:release-rust
Mar 17, 2026
Merged

csukuangfj merged 3 commits into
k2-fsa:masterfrom
csukuangfj:release-rust

Conversation

@csukuangfj

@csukuangfj csukuangfj commented Mar 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

Release Notes

  • New Features

    • Added offline and online speech denoiser support to the Rust API with configuration and audio processing capabilities.
    • Introduced denoised audio handling in the Kotlin API with file save functionality.
  • Refactor

    • Reorganized Kotlin API structure to separate audio denoising components.
  • Chores

    • Updated version to 0.1.11 across Rust packages.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 17, 2026
@coderabbitai

coderabbitai Bot commented Mar 17, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3464196-5ff6-49b8-b256-48339c7a6e49

📥 Commits

Reviewing files that changed from the base of the PR and between 45fb4f5 and 7117e23.

⛔ Files ignored due to path filters (1)
  • rust-api-examples/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (15)
  • android/SherpaOnnxAar/sherpa_onnx/src/main/java/com/k2fsa/sherpa/onnx/DenoisedAudio.kt
  • dotnet-examples/speech-enhancement-dpdfnet/run.sh
  • dotnet-examples/streaming-speech-enhancement-dpdfnet/run.sh
  • dotnet-examples/streaming-speech-enhancement-gtcrn/run.sh
  • kotlin-api-examples/DenoisedAudio.kt
  • kotlin-api-examples/run.sh
  • rust-api-examples/Cargo.toml
  • sherpa-onnx/kotlin-api/DenoisedAudio.kt
  • sherpa-onnx/kotlin-api/OfflineSpeechDenoiser.kt
  • sherpa-onnx/rust/sherpa-onnx-sys/Cargo.toml
  • sherpa-onnx/rust/sherpa-onnx/Cargo.toml
  • sherpa-onnx/rust/sherpa-onnx/src/lib.rs
  • sherpa-onnx/rust/sherpa-onnx/src/offline_speech_denoiser.rs
  • sherpa-onnx/rust/sherpa-onnx/src/online_speech_denoiser.rs
  • sherpa-onnx/rust/sherpa-onnx/src/speech_denoiser.rs

📝 Walkthrough

Walkthrough

This PR restructures the speech denoising APIs across Kotlin and Rust by extracting DenoisedAudio to a dedicated Kotlin file, reorganizing Rust denoiser implementations into separate modules, and updating version dependencies to 0.1.11 across Rust packages and examples.

Changes

Cohort / File(s) Summary
Kotlin API Restructuring
sherpa-onnx/kotlin-api/DenoisedAudio.kt, sherpa-onnx/kotlin-api/OfflineSpeechDenoiser.kt, android/SherpaOnnxAar/sherpa_onnx/src/main/java/com/k2fsa/sherpa/onnx/DenoisedAudio.kt, kotlin-api-examples/DenoisedAudio.kt
DenoisedAudio data class and its JNI surface extracted from OfflineSpeechDenoiser.kt into dedicated DenoisedAudio.kt file; references added to Android module and example configurations.
Rust Denoiser Module Reorganization
sherpa-onnx/rust/sherpa-onnx/src/offline_speech_denoiser.rs, sherpa-onnx/rust/sherpa-onnx/src/online_speech_denoiser.rs, sherpa-onnx/rust/sherpa-onnx/src/speech_denoiser.rs, sherpa-onnx/rust/sherpa-onnx/src/lib.rs
Denoiser wrapper structs moved from speech_denoiser.rs into dedicated offline_speech_denoiser.rs and online_speech_denoiser.rs modules; visibility of helper methods changed to pub(crate); new modules re-exported via lib.rs.
Version & Dependency Bumps
sherpa-onnx/rust/sherpa-onnx-sys/Cargo.toml, sherpa-onnx/rust/sherpa-onnx/Cargo.toml, rust-api-examples/Cargo.toml
Package versions and sherpa-onnx dependency versions bumped from 0.1.10 to 0.1.11 across Rust crates.
Build Configuration Updates
kotlin-api-examples/run.sh
DenoisedAudio.kt source file added to kotlinc-jvm compilation commands for both GTCRN and DPDFNet test pathways.

Possibly related PRs

  • Small fixes to JNI wrappers #3298: Fixes JNI local-ref management in offline-speech-denoiser.cc, complementing this PR's restructuring of the DenoisedAudio JNI surface.
  • Begin to add Rust API #3203: Adds initial Rust API and FFI crates; this PR extends those with dedicated denoiser module organization.
  • Fix bugs in CXX APIs #3296: Updates C/C++ DenoisedAudio struct defaults and destroy safeguards, aligning with this PR's API restructuring changes.

Suggested labels

size:XXL

Poem

🐰 We hop and reorganize with glee,
Moving audio data wild and free!
Rust modules split, Kotlin classes fly,
Denoising APIs reach toward the sky! ✨


🎯 4 (Complex) | ⏱️ ~45 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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

❤️ Share

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

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on expanding the speech processing capabilities by releasing new Rust packages for offline and online speech denoisers. It also includes a refactoring effort in the Kotlin API to improve code structure and maintainability, ensuring that the denoising functionalities are well-integrated and easily accessible across different platforms.

Highlights

  • New Rust Packages: Introduced new Rust packages for both offline and online speech denoiser functionalities, providing robust noise reduction capabilities.
  • Kotlin API Refactoring: Refactored the Kotlin API by moving the DenoisedAudio class into its own dedicated file for better modularity and organization.
  • Version Updates: Updated package versions across Rust Cargo.toml and Cargo.lock files from 0.1.10 to 0.1.11 to reflect the new release.
Changelog
  • android/SherpaOnnxAar/sherpa_onnx/src/main/java/com/k2fsa/sherpa/onnx/DenoisedAudio.kt
    • Added a symbolic link to the DenoisedAudio.kt file.
  • kotlin-api-examples/DenoisedAudio.kt
    • Added a symbolic link to the DenoisedAudio.kt file.
  • kotlin-api-examples/run.sh
    • Updated kotlinc-jvm compilation commands to include DenoisedAudio.kt.
  • rust-api-examples/Cargo.lock
    • Updated package versions for rust-api-examples, sherpa-onnx, and sherpa-onnx-sys to 0.1.11.
  • rust-api-examples/Cargo.toml
    • Updated the rust-api-examples package version and sherpa-onnx dependency version to 0.1.11.
  • sherpa-onnx/kotlin-api/DenoisedAudio.kt
    • Added a new Kotlin class DenoisedAudio with samples, sampleRate, and a save function.
  • sherpa-onnx/kotlin-api/OfflineSpeechDenoiser.kt
    • Removed the DenoisedAudio class definition, moving it to its own file.
  • sherpa-onnx/rust/sherpa-onnx-sys/Cargo.toml
    • Updated the package version to 0.1.11.
  • sherpa-onnx/rust/sherpa-onnx/Cargo.toml
    • Updated the package version and sherpa-onnx-sys dependency version to 0.1.11.
  • sherpa-onnx/rust/sherpa-onnx/src/lib.rs
    • Added and exposed new modules offline_speech_denoiser and online_speech_denoiser.
  • sherpa-onnx/rust/sherpa-onnx/src/offline_speech_denoiser.rs
    • Added a new Rust module defining OfflineSpeechDenoiserConfig and OfflineSpeechDenoiser structs and their methods.
  • sherpa-onnx/rust/sherpa-onnx/src/online_speech_denoiser.rs
    • Added a new Rust module defining OnlineSpeechDenoiserConfig and OnlineSpeechDenoiser structs and their methods.
  • sherpa-onnx/rust/sherpa-onnx/src/speech_denoiser.rs
    • Removed OfflineSpeechDenoiserConfig and OnlineSpeechDenoiserConfig structs.
    • Changed visibility of to_sys methods to pub(crate).
    • Changed DenoisedAudio::from_ptr visibility to pub(crate).
    • Removed OfflineSpeechDenoiser and OnlineSpeechDenoiser structs, indicating they were moved to dedicated files.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@csukuangfj
csukuangfj merged commit 33dc6b2 into k2-fsa:master Mar 17, 2026
1 check was pending
@csukuangfj
csukuangfj deleted the release-rust branch March 17, 2026 04:25

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces Rust packages for both offline and online speech denoisers. It includes adding new Rust files for these features, refactoring existing Rust and Kotlin code to separate concerns, and updating version numbers across several Cargo.toml and Cargo.lock files for the new release. The changes are well-structured. I've found a couple of minor issues regarding potential integer overflows in the new Rust code, which could occur with very large inputs.

sys::SherpaOnnxOfflineSpeechDenoiserRun(
self.ptr,
samples_ptr,
samples.len() as i32,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The cast samples.len() as i32 could lead to an integer overflow if the number of samples exceeds i32::MAX. This would wrap in release builds, leading to incorrect behavior. It's safer to use try_into() to handle this case, which will panic on overflow instead of silently producing incorrect results.

Suggested change
samples.len() as i32,
samples.len().try_into().expect("number of samples should fit in a 32-bit integer"),

sys::SherpaOnnxOnlineSpeechDenoiserRun(
self.ptr,
samples_ptr,
samples.len() as i32,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Similar to the offline denoiser, the cast samples.len() as i32 could lead to an integer overflow if the number of samples exceeds i32::MAX. This would wrap in release builds, leading to incorrect behavior. It's safer to use try_into() to handle this case, which will panic on overflow instead of silently producing incorrect results.

Suggested change
samples.len() as i32,
samples.len().try_into().expect("number of samples should fit in a 32-bit integer"),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant