4.8 KiB
TEN VAD Integration Guide
This guide explains how to integrate and use TEN VAD (Voice Activity Detection) in the XiaoZhi ESP32 Server.
Overview
TEN VAD is a high-performance voice activity detection system that can be used as an alternative to Silero VAD. It provides accurate voice detection with configurable thresholds and parameters.
Available Versions:
- TEN VAD (Original): Linux-only native library version
- TEN VAD ONNX: Cross-platform version with Windows, Linux, and macOS support
Installation
TEN VAD ONNX (Recommended - Cross-Platform)
Method 1: Automatic Installation
cd main/xiaozhi-server
python scripts/install_ten_vad_onnx.py
Method 2: Manual Installation
- Ensure you have the
ten-vad-1.0-ONNXdirectory available - Copy the necessary files to
models/ten-vad-onnx/ - Run the test script to verify:
python scripts/test_ten_vad_onnx.py
TEN VAD Original (Linux Only)
Method 1: Automatic Installation
cd main/xiaozhi-server
python scripts/install_ten_vad.py
Method 2: Manual Installation
- Install the TEN VAD package:
pip install ten-vad
- Create the model directory:
mkdir -p models/ten-vad
Configuration
Both TEN VAD configurations are available in your .config.yaml file:
TEN VAD ONNX (Cross-Platform)
VAD:
TenVAD_ONNX:
type: ten_vad_onnx
model_path: models/ten-vad-onnx
sample_rate: 16000
hop_size: 256 # TEN VAD frame size
frame_size: 512 # Processing frame size
threshold: 0.5
threshold_low: 0.2
min_silence_duration_ms: 1000
frame_window_threshold: 3
TEN VAD Original (Linux Only)
VAD:
TenVAD:
type: ten_vad
model_path: models/ten-vad
sample_rate: 16000
frame_size: 512
threshold: 0.5
threshold_low: 0.2
min_silence_duration_ms: 1000
frame_window_threshold: 3
Configuration Parameters
model_path: Path to the TEN VAD model filessample_rate: Audio sample rate (default: 16000 Hz)frame_size: Audio frame size for processing (default: 512 samples)threshold: High threshold for voice detection (0.0-1.0)threshold_low: Low threshold for voice detection (0.0-1.0)min_silence_duration_ms: Minimum silence duration to consider speech endedframe_window_threshold: Number of positive frames needed to detect voice
Usage
For Cross-Platform Support (Recommended)
selected_module:
VAD: TenVAD_ONNX # Use ONNX version for cross-platform support
For Linux-Only Systems
selected_module:
VAD: TenVAD # Original version (Linux only)
Performance Tuning
Sensitivity Adjustment
- More Sensitive: Lower
thresholdandthreshold_lowvalues - Less Sensitive: Higher
thresholdandthreshold_lowvalues
Responsiveness
- Faster Response: Lower
frame_window_thresholdvalue - More Stable: Higher
frame_window_thresholdvalue
End-of-Speech Detection
- Quicker Cutoff: Lower
min_silence_duration_ms - More Patient: Higher
min_silence_duration_ms
Troubleshooting
Common Issues
-
Import Error: Make sure
ten-vadpackage is installedpip install ten-vad -
Model Loading Error: Ensure the model path exists and is accessible
ls -la models/ten-vad/ -
Performance Issues: Try adjusting
frame_sizeorsample_rate
Debug Logging
Enable debug logging to see TEN VAD detection results:
log:
log_level: DEBUG
This will show periodic VAD detection results in the logs.
Comparison with Other VAD Systems
| Feature | TEN VAD ONNX | TEN VAD Original | Silero VAD |
|---|---|---|---|
| Platform Support | Windows, Linux, macOS | Linux only | Windows, Linux, macOS |
| Accuracy | High | High | High |
| Speed | Fast | Fast | Fast |
| Memory Usage | Medium | Medium | Low |
| Model Size | Medium | Medium | Small |
| Language Support | Multi | Multi | Multi |
| Installation | Manual setup | pip install | pip install |
Advanced Configuration
Custom Model Path
If you have a custom TEN VAD model:
VAD:
TenVAD:
model_path: /path/to/your/custom/model
Multiple Configurations
You can define multiple TEN VAD configurations:
VAD:
TenVAD_Sensitive:
type: ten_vad
threshold: 0.3
threshold_low: 0.1
TenVAD_Conservative:
type: ten_vad
threshold: 0.7
threshold_low: 0.4
Support
For issues specific to TEN VAD integration:
- Check the logs for error messages
- Verify the installation using the installation script
- Test with different threshold values
- Refer to the TEN VAD documentation: https://github.com/ten-framework/ten-vad
For general XiaoZhi ESP32 Server issues, refer to the main documentation.