mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
4.2 KiB
4.2 KiB
TEN VAD Integration Summary
Overview
TEN VAD has been successfully integrated into the XiaoZhi ESP32 Server as an alternative Voice Activity Detection (VAD) provider alongside the existing Silero VAD.
Files Added/Modified
New Files Created:
core/providers/vad/ten_vad.py- Main TEN VAD provider implementationscripts/install_ten_vad.py- Installation script for TEN VADscripts/test_ten_vad.py- Test script to verify TEN VAD installationexamples/ten_vad_example.py- Usage example and configuration guidedocs/ten-vad-integration.md- Comprehensive integration documentation
Modified Files:
requirements.txt- Addedten-vad==0.1.0dependencydata/.config.yaml- Added TEN VAD configuration sectionREADME.md- Updated VAD section to include TEN VAD
Configuration
TEN VAD configuration has been added to .config.yaml:
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
Usage
To use TEN VAD, update the selected module in your configuration:
selected_module:
VAD: TenVAD # Change from SileroVAD to TenVAD
Installation Steps
-
Install TEN VAD package:
cd main/xiaozhi-server python scripts/install_ten_vad.py -
Test the installation:
python scripts/test_ten_vad.py -
Update configuration:
selected_module: VAD: TenVAD -
Start the server:
python app.py
Key Features
- High Performance: TEN VAD provides accurate voice activity detection
- Configurable Thresholds: Dual threshold system for stable detection
- Sliding Window: Prevents false positives with frame-based detection
- Easy Integration: Follows the same interface as existing VAD providers
- Comprehensive Logging: Debug information for troubleshooting
Architecture Integration
TEN VAD integrates seamlessly with the existing VAD architecture:
core/utils/vad.py (Factory)
↓
core/providers/vad/ten_vad.py (TEN VAD Implementation)
↓
core/providers/vad/base.py (VAD Interface)
The integration follows the same pattern as other VAD providers:
- Implements
VADProviderBaseinterface - Uses the factory pattern for instantiation
- Processes Opus-encoded audio packets
- Returns boolean voice activity detection results
Configuration Options
Sensitivity Levels:
- Sensitive:
threshold: 0.3, threshold_low: 0.1 - Balanced:
threshold: 0.5, threshold_low: 0.2(default) - Conservative:
threshold: 0.7, threshold_low: 0.4
Performance Tuning:
frame_size: Audio processing frame size (default: 512)frame_window_threshold: Frames needed for voice detection (default: 3)min_silence_duration_ms: Silence duration to end speech (default: 1000ms)
Testing
The integration includes comprehensive testing:
- Installation Test: Verifies TEN VAD package installation
- Provider Creation Test: Tests VAD provider instantiation
- Audio Processing Test: Tests audio processing pipeline
- Configuration Loading Test: Tests factory method integration
Troubleshooting
Common issues and solutions:
- Import Error: Install TEN VAD with
pip install ten-vad - Model Loading Error: Ensure model path exists and is accessible
- Performance Issues: Adjust
frame_sizeorsample_rate - Detection Issues: Tune threshold values for your environment
Documentation
- Integration Guide:
docs/ten-vad-integration.md - Usage Example:
examples/ten_vad_example.py - Installation Script:
scripts/install_ten_vad.py - Test Script:
scripts/test_ten_vad.py
Next Steps
- Test TEN VAD with real audio input
- Compare performance with Silero VAD
- Fine-tune configuration parameters
- Consider adding more VAD providers if needed
Notes
- TEN VAD models will be downloaded automatically on first use
- The integration maintains backward compatibility with existing VAD providers
- All existing VAD functionality remains unchanged
- TEN VAD can be easily switched on/off via configuration