Skip to content

Support ten vad - #2377

Merged
csukuangfj merged 5 commits into
k2-fsa:masterfrom
csukuangfj:support-ten-vad
Jul 11, 2025
Merged

Support ten vad#2377
csukuangfj merged 5 commits into
k2-fsa:masterfrom
csukuangfj:support-ten-vad

Conversation

@csukuangfj

@csukuangfj csukuangfj commented Jul 11, 2025

Copy link
Copy Markdown
Collaborator

Fixes #2329

Note that the pitch feature is set to 0, which may degrade the performance but can greatly simplify the implementation.

We use TEN-framework/ten-vad#36 as a reference.

CC @shenjinti

Please see
https://github.com/k2-fsa/sherpa-onnx/blob/master/python-api-examples/generate-subtitles.py
for how to use ten-vad.onnx with ASR for generating subtitles.

File size comparison between silero-vad (version 4) and ten-vad

Model name File size Download address License
silero_vad.onnx 629 KB Download MIT, yes for commercial use
silero_vad.int8.onnx 208 KB Download MIT, yes for commercial use
ten-vad.onnx 324 KB Download LICENSE
ten-vad.int8.onnx 126 KB Download LICENSE

ten-vad.onnx is from https://github.com/TEN-framework/ten-vad/blob/main/src/onnx_model/ten-vad.onnx
But we have added some meta data to it, e.g., mean and inv_stddev for feature normalization. So you have to use the model with metadata from us.

Summary by CodeRabbit

  • New Features

    • Added support for an alternative VAD model ("ten-vad.onnx") alongside the existing "silero_vad.onnx" in both C++ and Python APIs.
    • Users can now select and configure either VAD model via command-line arguments or Python bindings.
    • Exposed TenVadModelConfig in the Python API for advanced VAD configuration.
  • Bug Fixes

    • Corrected typographical errors in comments and warning messages.
  • Documentation

    • Updated comments and help texts for clarity and accuracy.
  • Chores

    • Updated third-party dependency to kaldi-native-fbank version 1.21.3.

@csukuangfj
csukuangfj requested a review from Copilot July 11, 2025 12:31
@coderabbitai

coderabbitai Bot commented Jul 11, 2025

Copy link
Copy Markdown

Walkthrough

The changes introduce support for the TEN-VAD voice activity detection model across the C++ core, Python bindings, and example scripts. This includes new configuration and model classes for TEN-VAD, integration into model selection logic, updates to command-line arguments, and Python API exposure. Minor typo corrections and build script updates are also included.

Changes

File(s) Change Summary
cmake/kaldi-native-fbank.cmake Updated kaldi-native-fbank version and related URLs/hashes.
cxx-api-examples/zipformer-transducer-simulate-streaming-microphone-cxx-api.cc Minor comment rewording in file header.
python-api-examples/generate-subtitles.py Added support for TEN-VAD model selection and configuration; updated argument parsing and logic.
sherpa-onnx/csrc/CMakeLists.txt, sherpa-onnx/python/csrc/CMakeLists.txt Added TEN-VAD source files to build system.
sherpa-onnx/csrc/silero-vad-model-config.cc, sherpa-onnx/csrc/silero-vad-model-config.h Typo fix and comment removal.
sherpa-onnx/csrc/ten-vad-model-config.h, sherpa-onnx/csrc/ten-vad-model-config.cc New TEN-VAD configuration struct and implementation.
sherpa-onnx/csrc/ten-vad-model.h, sherpa-onnx/csrc/ten-vad-model.cc New TEN-VAD model class and implementation.
sherpa-onnx/csrc/transpose.h Typo fix in comment.
sherpa-onnx/csrc/vad-model-config.h, sherpa-onnx/csrc/vad-model-config.cc Added TEN-VAD config member and logic for registration/validation.
sherpa-onnx/csrc/vad-model.cc Added TEN-VAD support to VAD model factory logic.
sherpa-onnx/csrc/voice-activity-detector.cc Conditional logic for multiple VAD model types.
sherpa-onnx/python/csrc/ten-vad-model-config.h, sherpa-onnx/python/csrc/ten-vad-model-config.cc New Python bindings for TEN-VAD config.
sherpa-onnx/python/csrc/vad-model-config.cc Exposed TEN-VAD config in Python bindings.
sherpa-onnx/python/sherpa_onnx/init.py Exported TenVadModelConfig in Python API.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PythonScript
    participant VadModelConfig
    participant VadModelFactory
    participant SileroVadModel
    participant TenVadModel

    User->>PythonScript: Run with --silero-vad-model or --ten-vad-model
    PythonScript->>VadModelConfig: Parse and validate config
    PythonScript->>VadModelFactory: Create(config)
    alt silero_vad.model is set
        VadModelFactory->>SileroVadModel: Instantiate
    else ten_vad.model is set
        VadModelFactory->>TenVadModel: Instantiate
    else
        VadModelFactory->>PythonScript: Error (no model)
    end
    PythonScript->>User: Process audio with selected VAD model
Loading

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Add support for TEN-VAD model in C++ core (#2329)
Add TEN-VAD configuration and selection in Python API (#2329)
Integrate TEN-VAD into build system and examples (#2329)
Expose TEN-VAD configuration via Python bindings (#2329)

Poem

In the land of code where rabbits hop,
TEN-VAD joins the speech-detecting crop!
With configs and bindings, both C++ and Py,
Now silence and speech are easy to spy.
From build to example, the patch is complete—
This bunny’s approval can’t be beat! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ec5567 and 10b2942.

📒 Files selected for processing (2)
  • sherpa-onnx/csrc/ten-vad-model.cc (1 hunks)
  • sherpa-onnx/csrc/transpose.h (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • sherpa-onnx/csrc/transpose.h
  • sherpa-onnx/csrc/ten-vad-model.cc
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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 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 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.

Copilot AI 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.

Pull Request Overview

This PR adds support for the TEN VAD model alongside the existing Silero VAD in both C++ and Python interfaces.

  • Introduces TenVadModelConfig with Python bindings and integrates it into VadModelConfig.
  • Implements TenVadModel in C++ and extends the factory (VadModel::Create) and detector logic to choose between Silero and TEN VAD.
  • Updates build files (CMake), fixes a spelling typo, and extends the Python example script to demonstrate --ten-vad-model.

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
python/sherpa_onnx/init.py Import TenVadModelConfig
python/csrc/vad-model-config.cc Extend Python binding for VadModelConfig with ten_vad
python/csrc/ten-vad-model-config.h/cc Add Python binding for TenVadModelConfig
python/csrc/CMakeLists.txt Include ten-vad-model-config.cc in build
csrc/voice-activity-detector.cc Handle ten_vad in detector implementation
csrc/vad-model.cc Extend factory to create TenVadModel
csrc/vad-model-config.h/cc Integrate TenVadModelConfig into config struct and parsing
csrc/ten-vad-model.h/cc Implement TenVadModel class
csrc/silero-vad-model-config.cc Fix spelling from “perfomance” to “performance”
csrc/CMakeLists.txt Add TEN VAD model files to build
python-api-examples/generate-subtitles.py Update example to support --ten-vad-model
cxx-api-examples/zipformer-...-microphone.cc Minor comment formatting fix
cmake/kaldi-native-fbank.cmake Bump kaldi-native-fbank dependency to v1.21.3
Comments suppressed due to low confidence (3)

sherpa-onnx/python/csrc/vad-model-config.cc:25

  • The constructor argument name 'ten' mismatches the property 'ten_vad'. Rename the argument to 'ten_vad' for consistency with the .def_readwrite("ten_vad", ...) binding.
           py::arg("ten") = TenVadModelConfig{}, py::arg("sample_rate") = 16000,

sherpa-onnx/csrc/ten-vad-model-config.cc:42

  • Consider adding unit tests for TenVadModelConfig::Validate to ensure both valid and invalid configurations are correctly detected.
bool TenVadModelConfig::Validate() const {

sherpa-onnx/csrc/silero-vad-model-config.h:27

  • [nitpick] Consider restoring the removed comment about valid window_size values for 8000 Hz (e.g., 256, 512, 768 samples) to help users configure the model correctly.
  int32_t window_size = 512;  // in samples

Comment thread sherpa-onnx/csrc/ten-vad-model.cc Outdated

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🧹 Nitpick comments (9)
sherpa-onnx/csrc/transpose.h (1)

23-24: Spelling now inconsistent between the two doc-blocks

Great catch fixing “data type” here, but the earlier comment for Transpose01 (line 13) still says “dataype”, and line 15 uses “datatype” (no space). For consistency and clarity, fix both instances.

- * @param v A 3-D tensor of shape (B, T, C). Its dataype is type.
- *
- * @return Return a 3-D tensor of shape (T, B, C). Its datatype is type.
+ * @param v A 3-D tensor of shape (B, T, C). Its data type is type.
+ *
+ * @return Return a 3-D tensor of shape (T, B, C). Its data type is type.
sherpa-onnx/python/csrc/CMakeLists.txt (1)

54-55: Source list stays consistent – optional alphabetical placement

ten-vad-model-config.cc is correctly appended and will be built.
For long lists it’s easier to scan when kept alphabetical (like the surrounding block), but this is purely cosmetic.

sherpa-onnx/csrc/CMakeLists.txt (1)

126-127: Remember to add headers for IDE code-navigation

The new .cc files are registered, but the corresponding headers (ten-vad-model.h, ten-vad-model-config.h) are not listed anywhere.
Some IDEs/clang-tools rely on header entries in the build graph for proper include-path deduction. Consider adding them to an install(FILES …) clause or an IDE helper target.

sherpa-onnx/python/sherpa_onnx/__init__.py (1)

67-69: Silence Ruff F401 for re-exported symbol

TenVadModelConfig is intentionally imported for re-export, but Ruff flags it as unused.
Add a file-level or per-line # noqa: F401 to keep the lint pipeline green:

-    TenVadModelConfig,
+    TenVadModelConfig,  # noqa: F401  (re-export)
sherpa-onnx/python/csrc/vad-model-config.cc (1)

22-25: Consider consistent parameter naming.

The constructor parameter is named ten but the class property is ten_vad. This naming inconsistency could cause confusion for users.

Consider renaming the parameter for consistency:

-      .def(py::init<const SileroVadModelConfig &, const TenVadModelConfig &,
-                    int32_t, int32_t, const std::string &, bool>(),
-           py::arg("silero_vad") = SileroVadModelConfig{},
-           py::arg("ten") = TenVadModelConfig{}, py::arg("sample_rate") = 16000,
+      .def(py::init<const SileroVadModelConfig &, const TenVadModelConfig &,
+                    int32_t, int32_t, const std::string &, bool>(),
+           py::arg("silero_vad") = SileroVadModelConfig{},
+           py::arg("ten_vad") = TenVadModelConfig{}, py::arg("sample_rate") = 16000,
sherpa-onnx/csrc/ten-vad-model-config.cc (1)

36-40: Remove trailing space and consider enforcing the recommended window sizes.

The warning message has a trailing space after "256". Additionally, since the warning strongly recommends using 160 or 256, consider validating these specific values in the Validate() method.

   po->Register(
       "ten-vad-window-size", &window_size,
       "In samples. Audio chunks of --ten-vad-window-size samples are fed "
-      "to the ten VAD model. WARNING! Please use 160 or 256 ");
+      "to the ten VAD model. WARNING! Please use 160 or 256");
sherpa-onnx/csrc/ten-vad-model.cc (3)

168-172: Align window size validation with configuration recommendations.

The validation allows window sizes up to 768, but the configuration file strongly recommends using 160 or 256. Consider tightening this validation or at least warning about non-recommended values.

   if (config_.ten_vad.window_size > 768) {
     SHERPA_ONNX_LOGE("Windows size %d for ten-vad is too large",
                      config_.ten_vad.window_size);
     SHERPA_ONNX_EXIT(-1);
   }
+
+  if (config_.ten_vad.window_size != 160 && config_.ten_vad.window_size != 256) {
+    SHERPA_ONNX_LOGW("Recommended window sizes are 160 or 256. Given: %d",
+                     config_.ten_vad.window_size);
+  }

352-354: Add more context to the pitch feature comment.

While setting pitch to 0 is mentioned in the PR objectives, the inline comment could be more descriptive for future maintainers.

   // we use 0 for the pitch
+  // Note: The ten-vad model expects a pitch feature, but we set it to 0
+  // as a simplification. This may reduce performance as noted in the PR.
   features_.back() = 0;

284-288: Add documentation for the Scale method.

The method scales normalized float samples to int16 range, but this purpose isn't documented.

+  // Scales normalized float samples [-1, 1] to int16 range [-32768, 32767]
   static void Scale(const float *samples, int32_t n, float *out) {
     for (int32_t i = 0; i != n; ++i) {
       out[i] = samples[i] * 32768;
     }
   }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bebd996 and 5fd958e.

📒 Files selected for processing (20)
  • cmake/kaldi-native-fbank.cmake (2 hunks)
  • cxx-api-examples/zipformer-transducer-simulate-streaming-microphone-cxx-api.cc (1 hunks)
  • python-api-examples/generate-subtitles.py (4 hunks)
  • sherpa-onnx/csrc/CMakeLists.txt (1 hunks)
  • sherpa-onnx/csrc/silero-vad-model-config.cc (1 hunks)
  • sherpa-onnx/csrc/silero-vad-model-config.h (0 hunks)
  • sherpa-onnx/csrc/ten-vad-model-config.cc (1 hunks)
  • sherpa-onnx/csrc/ten-vad-model-config.h (1 hunks)
  • sherpa-onnx/csrc/ten-vad-model.cc (1 hunks)
  • sherpa-onnx/csrc/ten-vad-model.h (1 hunks)
  • sherpa-onnx/csrc/transpose.h (1 hunks)
  • sherpa-onnx/csrc/vad-model-config.cc (2 hunks)
  • sherpa-onnx/csrc/vad-model-config.h (2 hunks)
  • sherpa-onnx/csrc/vad-model.cc (3 hunks)
  • sherpa-onnx/csrc/voice-activity-detector.cc (3 hunks)
  • sherpa-onnx/python/csrc/CMakeLists.txt (1 hunks)
  • sherpa-onnx/python/csrc/ten-vad-model-config.cc (1 hunks)
  • sherpa-onnx/python/csrc/ten-vad-model-config.h (1 hunks)
  • sherpa-onnx/python/csrc/vad-model-config.cc (1 hunks)
  • sherpa-onnx/python/sherpa_onnx/__init__.py (1 hunks)
💤 Files with no reviewable changes (1)
  • sherpa-onnx/csrc/silero-vad-model-config.h
🧰 Additional context used
🧬 Code Graph Analysis (4)
sherpa-onnx/csrc/vad-model-config.cc (5)
sherpa-onnx/csrc/silero-vad-model-config.h (1)
  • po (36-36)
sherpa-onnx/csrc/ten-vad-model-config.h (1)
  • po (36-36)
sherpa-onnx/csrc/vad-model-config.h (1)
  • po (38-38)
sherpa-onnx/csrc/silero-vad-model-config.cc (2)
  • ToString (102-114)
  • ToString (102-102)
sherpa-onnx/csrc/ten-vad-model-config.cc (2)
  • ToString (97-109)
  • ToString (97-97)
sherpa-onnx/csrc/voice-activity-detector.cc (2)
sherpa-onnx/csrc/ten-vad-model.cc (2)
  • config_ (146-146)
  • config_ (148-148)
sherpa-onnx/csrc/silero-vad-model.cc (2)
  • config_ (157-157)
  • config_ (159-161)
sherpa-onnx/python/csrc/vad-model-config.cc (4)
sherpa-onnx/python/csrc/silero-vad-model-config.cc (2)
  • PybindSileroVadModelConfig (14-45)
  • PybindSileroVadModelConfig (14-14)
sherpa-onnx/python/csrc/silero-vad-model-config.h (1)
  • PybindSileroVadModelConfig (12-12)
sherpa-onnx/python/csrc/ten-vad-model-config.h (1)
  • PybindTenVadModelConfig (12-12)
sherpa-onnx/python/csrc/ten-vad-model-config.cc (2)
  • PybindTenVadModelConfig (14-45)
  • PybindTenVadModelConfig (14-14)
sherpa-onnx/csrc/ten-vad-model.h (2)
sherpa-onnx/csrc/ten-vad-model.cc (21)
  • TenVadModel (435-436)
  • TenVadModel (439-440)
  • TenVadModel (442-442)
  • TenVadModel (471-472)
  • TenVadModel (476-477)
  • samples (74-144)
  • samples (74-74)
  • samples (284-288)
  • samples (284-284)
  • samples (290-300)
  • samples (290-290)
  • samples (302-307)
  • samples (302-303)
  • samples (334-362)
  • samples (334-334)
  • samples (364-395)
  • samples (364-364)
  • s (154-156)
  • s (154-154)
  • threshold (158-158)
  • threshold (158-158)
sherpa-onnx/csrc/voice-activity-detector.cc (2)
  • samples (44-123)
  • samples (44-44)
🪛 Ruff (0.11.9)
sherpa-onnx/python/sherpa_onnx/__init__.py

67-67: _sherpa_onnx.TenVadModelConfig imported but unused

(F401)

🔇 Additional comments (31)
cxx-api-examples/zipformer-transducer-simulate-streaming-microphone-cxx-api.cc (1)

4-5: Comment wording tweak is fine – no action needed

Only a comment re-flow; no functional impact.

sherpa-onnx/csrc/silero-vad-model-config.cc (1)

40-44: Typo fix looks good

“performance” spelling corrected – no further issues.

sherpa-onnx/python/csrc/ten-vad-model-config.h (1)

1-17: LGTM! Clean header file structure.

The header file follows proper conventions with include guards, namespace usage, and function declaration for Python bindings.

cmake/kaldi-native-fbank.cmake (2)

15-19: File paths updated consistently.

All local file path references have been updated to reflect the new version number.


4-6: Dependency update verified: kaldi-native-fbank v1.21.3 archive is accessible and its SHA256 (d409eddae5a46dc796f0841880f489ff0728b96ae26218702cd438c28667c70e) matches the CMake setting. No further action required.

sherpa-onnx/csrc/vad-model-config.cc (3)

16-17: Good integration of TEN-VAD registration.

The registration of both VAD models is implemented correctly, maintaining consistency with the existing pattern.


52-63: Excellent validation logic for dual VAD model support.

The validation approach correctly handles either VAD model configuration:

  • Validates silero_vad if provided
  • Falls back to ten_vad if silero_vad is not provided
  • Provides clear error message if neither is configured

This maintains backward compatibility while enabling the new TEN-VAD support.


69-70: ToString method properly updated.

The string representation now includes both VAD model configurations, maintaining consistency with the existing format.

sherpa-onnx/csrc/vad-model-config.h (3)

11-11: Proper header inclusion.

The inclusion of the TEN-VAD model configuration header is correctly placed.


16-17: Member addition follows existing pattern.

The ten_vad member is added consistently with the existing silero_vad member.


28-36: No action needed: constructor parameters are in correct order

I’ve verified that the constructor’s parameter list (silero_vad, ten_vad, sample_rate, num_threads, provider, debug) matches the declaration order of the struct members. No changes required.

sherpa-onnx/csrc/voice-activity-detector.cc (3)

21-21: Appropriate header inclusion for error handling.

The inclusion of macros.h provides the necessary error logging and exit macros used in the conditional logic.


49-58: Excellent conditional logic for dual VAD model support.

The implementation correctly handles both VAD models:

  • Checks silero_vad first for backward compatibility
  • Falls back to ten_vad if silero_vad is not configured
  • Provides clear error handling for unknown models

The error handling using SHERPA_ONNX_LOGE and SHERPA_ONNX_EXIT is appropriate for this critical configuration error.


172-181: Consistent initialization logic.

The Init method uses the same conditional pattern as AcceptWaveform, ensuring consistent behavior across the class. The error handling for unsupported VAD models is appropriate.

sherpa-onnx/python/csrc/ten-vad-model-config.cc (1)

1-48: Well-structured pybind11 bindings implementation.

The implementation follows established patterns from the existing SileroVadModelConfig bindings and provides appropriate default values for the TEN-VAD model configuration parameters.

sherpa-onnx/python/csrc/vad-model-config.cc (3)

11-11: LGTM: Correct include addition.

The include statement properly adds the TEN-VAD model configuration header.


17-17: LGTM: Proper registration of TEN-VAD bindings.

The call to PybindTenVadModelConfig(m) correctly registers the new TEN-VAD model configuration class.


29-29: LGTM: Proper property exposure.

The ten_vad property is correctly exposed as a read-write attribute.

sherpa-onnx/csrc/vad-model.cc (6)

22-22: LGTM: Proper include addition.

The include statement correctly adds the TEN-VAD model header.


29-34: LGTM: Proper RKNN provider validation.

The implementation correctly validates that only Silero VAD is supported for RKNN provider and provides appropriate error handling.


44-50: LGTM: Well-structured fallback logic.

The factory method properly implements fallback logic by checking for Silero VAD first, then TEN-VAD, ensuring at least one model is provided.


52-53: LGTM: Appropriate error handling.

The error logging and null return provide proper handling when no VAD model is specified.


61-66: LGTM: Consistent RKNN validation in template method.

The template method correctly mirrors the same RKNN provider validation logic as the main factory method.


75-84: LGTM: Consistent fallback logic in template method.

The template method properly implements the same fallback logic as the main factory method.

sherpa-onnx/csrc/ten-vad-model-config.h (1)

1-45: Well-structured configuration header.

The TenVadModelConfig struct follows the established pattern from SileroVadModelConfig with appropriate default values and standard methods. The default window size of 256 is consistent with the comment indicating valid values of 160 or 256.

python-api-examples/generate-subtitles.py (3)

22-26: LGTM: Good documentation update.

The documentation properly explains the new TEN-VAD model option and usage.


131-140: LGTM: Proper argument handling for dual VAD support.

The command-line argument changes correctly make both VAD models optional while requiring at least one to be specified.


513-518: LGTM: Proper validation logic.

The validation ensures at least one VAD model is provided with appropriate error handling.

sherpa-onnx/csrc/ten-vad-model-config.cc (2)

60-65: Clarify if threshold value 1.0 should be allowed.

The current validation rejects threshold values >= 1. If 1.0 represents 100% probability and is a valid threshold, consider using > 1 instead.


97-109: LGTM!

The ToString() method is well-implemented with proper formatting.

sherpa-onnx/csrc/ten-vad-model.cc (1)

243-250: Great error messaging for model validation!

The error message clearly explains the issue and provides actionable guidance for users to download the correct model version with metadata.

Comment thread python-api-examples/generate-subtitles.py
Comment thread sherpa-onnx/csrc/ten-vad-model-config.cc
Comment thread sherpa-onnx/csrc/ten-vad-model.h Outdated
Comment thread sherpa-onnx/csrc/ten-vad-model.cc
csukuangfj and others added 3 commits July 11, 2025 20:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@csukuangfj
csukuangfj merged commit 19ac7d5 into k2-fsa:master Jul 11, 2025
105 of 228 checks passed
@csukuangfj
csukuangfj deleted the support-ten-vad branch July 11, 2025 13:19
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.

Support TEN-VAD

2 participants