Repository navigation
Add Java/Kotlin API and Android support for ten-vad - #2389
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThis change introduces support for the "ten-vad" voice activity detection model across Java, Kotlin, JNI, and CI workflows. It adds new configuration classes, a Java example, build and run scripts, and updates documentation. Additionally, download URLs for the silero VAD model are updated throughout the codebase to point to the k2-fsa GitHub releases. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant JavaApp as TenVadRemoveSilence.java
participant JNI
participant NativeLib as C++ VAD Core
User->>JavaApp: Run TenVadRemoveSilence (with ten-vad.onnx)
JavaApp->>JNI: Initialize Vad with TenVadModelConfig
JNI->>NativeLib: Pass ten-vad config to C++ core
JavaApp->>JavaApp: Read and process audio in windows
JavaApp->>JNI: Feed audio window to Vad
JNI->>NativeLib: Process window for speech segments
NativeLib-->>JNI: Return detected segments
JNI-->>JavaApp: Return detected segments
JavaApp->>JavaApp: Collect and concatenate speech segments
JavaApp->>JavaApp: Save output audio without silence
JavaApp->>JNI: Release Vad resources
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (35)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for the new ten-vad model across Kotlin, Java, JNI, Android builds, and examples.
- Introduce TenVadModelConfig in Kotlin and Java APIs and wire it through JNI.
- Extend Android build script and CI to produce APKs with ten-vad.
- Provide Java example and scripts for ten-vad-based silence removal.
Reviewed Changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| sherpa-onnx/kotlin-api/Vad.kt | Added TenVadModelConfig and integrated it into getVadModelConfig |
| sherpa-onnx/jni/voice-activity-detector.cc | JNI parsing for TenVadModelConfig fields |
| sherpa-onnx/java-api/src/com/k2fsa/sherpa/onnx/VadModelConfig.java | Added builder and accessor for TenVadModelConfig |
| sherpa-onnx/java-api/src/com/k2fsa/sherpa/onnx/TenVadModelConfig.java | New Java class for ten-vad configuration |
| sherpa-onnx/java-api/Makefile | Included TenVadModelConfig.java in the Java API build |
| scripts/apk/build-apk-vad.sh | Updated Android APK build to include ten-vad model |
| .github/workflows/run-java-test.yaml | CI job to run the ten-vad remove-silence example |
| java-api-examples/run-ten-vad-remove-slience.sh | Demo script for running the ten-vad silence removal example |
| java-api-examples/TenVadRemoveSilence.java | Java example illustrating silence removal via ten-vad |
Comments suppressed due to low confidence (3)
sherpa-onnx/java-api/src/com/k2fsa/sherpa/onnx/TenVadModelConfig.java:55
- Default windowSize (256) differs from the Kotlin default (512). Align defaults across languages to maintain a consistent API.
private int windowSize = 256;
sherpa-onnx/java-api/src/com/k2fsa/sherpa/onnx/TenVadModelConfig.java:54
- Default minSpeechDuration (0.5f) is inconsistent with the Kotlin default (0.25F). Consider unifying this value across both APIs.
private float minSpeechDuration = 0.5f;
sherpa-onnx/kotlin-api/Vad.kt:129
- The new case for
type = 1(ten-vad) ingetVadModelConfiglacks unit tests. Add tests to verify that ten-vad configurations are built and parsed correctly.
1 -> {
| @@ -0,0 +1,39 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
The script filename and references to 'slience' are misspelled. Rename to 'run-ten-vad-remove-silence.sh' and update occurrences to 'silence'.
| # Now for ten-vad | ||
| git checkout . | ||
| pushd android/SherpaOnnxVad/app/src/main/java/com/k2fsa/sherpa/onnx | ||
| sed -i.bak s/"type = 0/type = 1/" ./MainActivity.kt |
There was a problem hiding this comment.
[nitpick] Modifying source with sed can be fragile. Consider using a build flag or configuration to switch model types instead of in-place edits.
You can find the Android APK for ten-vad at
https://k2-fsa.github.io/sherpa/onnx/vad/apk.html
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores