Repository navigation
Add Dart API for ten-vad - #2386
Conversation
WalkthroughThis change adds support for a new "ten-vad" voice activity detection (VAD) model in the Dart and Flutter bindings. It introduces new configuration structs, updates the VAD configuration data structures, implements a Dart example for ten-vad, and adds scripts to automate testing and usage of the new model. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Script (run-ten-vad.sh)
participant DartApp (ten-vad.dart)
participant SherpaONNX
User->>Script (run-ten-vad.sh): Execute script
Script->>Script: Ensure model & audio files are present
Script->>DartApp: Run ten-vad.dart with args
DartApp->>SherpaONNX: Initialize VAD with ten-vad config
DartApp->>DartApp: Read input WAV, process in chunks
DartApp->>SherpaONNX: Feed audio chunks to VAD
SherpaONNX-->>DartApp: Return detected speech segments
DartApp->>DartApp: Collect & concatenate speech segments
DartApp->>DartApp: Write output WAV file
DartApp->>Script: Print output file info
Script->>User: Display WAV file details
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
⏰ 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). (2)
🔇 Additional comments (8)
✨ 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 “tenVad” voice activity detection model to the Dart and Flutter APIs, updates FFI bindings, and extends the CI and example scripts to exercise the new functionality.
- Introduces
TenVadModelConfigand integrates it intoVadModelConfigandVoiceActivityDetector - Extends FFI struct bindings to include
SherpaOnnxTenVadModelConfig - Adds a shell script and CI updates to run the new ten-vad example
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| flutter/sherpa_onnx/lib/src/vad.dart | Added TenVadModelConfig, wired it into VadModelConfig, VoiceActivityDetector, and JSON methods |
| flutter/sherpa_onnx/lib/src/sherpa_onnx_bindings.dart | Added FFI struct SherpaOnnxTenVadModelConfig and updated SherpaOnnxVadModelConfig binding |
| dart-api-examples/vad/run-ten-vad.sh | New example script to download models/audio and run the ten-vad demo |
| .github/scripts/test-dart.sh | Updated CI script to invoke the ten-vad example alongside existing tests |
Comments suppressed due to low confidence (3)
flutter/sherpa_onnx/lib/src/vad.dart:52
- Consider adding unit tests for
TenVadModelConfig.fromJsonandtoJsonto validate serialization and deserialization of each field.
class TenVadModelConfig {
flutter/sherpa_onnx/lib/src/sherpa_onnx_bindings.dart:523
- The
tenVadfield is declared afterdebug, which may not match the native C struct layout. Ensure the Dart FFI struct fields are in the exact same order as the C definition (likely immediately aftersileroVad).
external SherpaOnnxTenVadModelConfig tenVad;
flutter/sherpa_onnx/lib/src/vad.dart:218
- Wrap native memory allocations and assignments in a
try/finallyblock to ensure all allocated pointers (e.g.,modelPtr,tenVadModelPtr) are freed even if an exception occurs.
final c = calloc<SherpaOnnxVadModelConfig>();
Summary by CodeRabbit
New Features
Chores