VoiceTrigger
VoiceTrigger 是一款 Minecraft NeoForge 模组,允许玩家通过语音指令控制游戏按键。它结合了 Wav2Vec2 深度学习模型与经过自定义训练的模型进行语音识别和匹配,为 Minecraft 带来沉浸式的语音控制体验。
功能特性
- 语音键位绑定:将自定义语音指令绑定到任意游戏内按键
- 深度学习语音识别:基于 Wav2Vec2 模型的高精度语音匹配
- 实时语音监控:支持持续监控模式和按键触发模式
- 静音检测:智能检测语音的起止点,自动过滤静音片段
- 可配置参数:可调节相似度、静音等阈值及其他参数
系统要求
- Minecraft 1.21.1
- NeoForge 21.1.209+
- Java 21+
- 麦克风设备
安装方法
- 确保已安装 NeoForge 1.21.1
- 下载最新的 VoiceTrigger 模组 JAR 文件
- 将 JAR 文件放入
.minecraft/mods 目录
- 启动游戏
使用方法
打开语音绑定界面
在游戏中按下 B(默认)以打开语音绑定设置界面。
录制语音模板
- 在语音绑定界面中,找到要绑定的按键
- 点击“Record”按钮开始录制
- 对着麦克风说出你希望的语音指令(建议时长:2-3 秒)
- 点击“Stop”结束录制
- 语音模板将自动保存并注册
语音触发模式
该模组支持两种语音监控模式(可配置):
| 模式 |
描述 |
| Continuous (ON) |
在游戏世界中自动监控麦克风,暂停游戏时停止监听 |
| Key-triggered (OFF) |
仅在按住 V 键时进行监听 |
配置
配置文件路径:.minecraft/config/voice_trigger-client.toml
# 相似度阈值(必须超过此值才能匹配)
# 范围:0.0 ~ 1.0,默认值:0.75
similarityThreshold = 0.75
# 静音检测阈值(dB)
# 默认值:-43.0
silenceThreshold = -43.0
# 音频缓冲区大小(字节)
# 范围:1024 ~ 16384,默认值:4096
bufferSize = 4096
# 匹配所需的最小帧数
# 范围:1 ~ 16,默认值:3
minFramesForMatch = 3
# 持续监控模式
# ON:持续监控麦克风
# OFF:仅当按住 V 键时监听
continuousMonitoring = "ON"
配置建议
- 识别率低:降低
similarityThreshold(例如 0.65)
- 频繁误触发:提高
similarityThreshold(例如 0.85)
- 录音过短:增加
minFramesForMatch
- 环境嘈杂:提高
silenceThreshold(例如 -35.0)
开发指南
环境要求
克隆项目
git clone https://github.com/your-repo/VoiceTrigger.git
cd VoiceTrigger
构建项目
# Windows
gradlew.bat build
# Linux/macOS
./gradlew build
构建产物位于 build/libs/ 目录下。
运行开发环境
# 启动客户端
gradlew.bat runClient
# 启动服务器
gradlew.bat runServer
生成语言文件
gradlew.bat runData
技术架构
核心组件
| 组件 |
描述 |
VoiceListener |
实时语音监听器,处理麦克风输入和语音匹配 |
VoiceRecorder |
语音录制器,用于捕获用户语音模板 |
VoiceProfileManager |
管理 WAV 文件的存储和加载 |
AudioSimilarityDL |
基于 Wav2Vec2 模型的深度学习音频相似度计算 |
依赖项
- TarsosDSP:音频处理和麦克风输入
- DJL (Deep Java Library):深度学习推理框架
- PyTorch Engine:Wav2Vec2 模型运行时
语音配置文件存储
语音模板存储在:.minecraft/config/voice_trigger/*.wav
文件命名格式:{key_name}.wav
键位绑定
| 按键 |
功能 |
B |
打开语音绑定界面 |
V |
语音监控(仅在 continuousMonitoring=OFF 时有效) |
常见问题
Q: 语音识别不工作?
- 验证麦克风功能是否正常
- 确认游戏声音设置中已启用麦克风
- 检查
logs/latest.log 中的错误信息
Q: 识别率低?
- 重新录制更清晰的语音模板
- 建议录制时长:2-3 秒
- 降低
similarityThreshold 的值
- 确保在安静的环境中录制
Q: 误触发过多?
- 提高
similarityThreshold 的值
- 使用更具区分度的语音指令
- 提高
silenceThreshold 以过滤背景噪音
开源许可
采用 GNU Lesser General Public License v3.0 许可。
作者
致谢
VoiceTrigger
VoiceTrigger is a Minecraft NeoForge mod that allows players to control game keys via voice commands. It utilizes the Wav2Vec2 deep learning
model combined with custom-trained models for speech recognition and matching, delivering an immersive voice control experience for
Minecraft.
Features
- Voice Key Binding: Bind custom voice commands to any in-game key
- Deep Learning Speech Recognition: High-precision voice matching based on the Wav2Vec2 model
- Real-time Voice Monitoring: Supports both continuous monitoring and key-triggered modes
- Silence Detection: Intelligent detection of speech start/end points, automatically filtering silent segments
- Configurable Parameters: Adjustable thresholds for similarity, silence, and other parameters
System Requirements
- Minecraft 1.21.1
- NeoForge 21.1.209+
- Java 21+
- Microphone device
Installation
- Ensure NeoForge 1.21.1 is installed
- Download the latest VoiceTrigger mod JAR file
- Place the JAR file in
.minecraft/mods directory
- Launch the game
Usage
Opening Voice Binding Interface
Press B (default) in-game to open the voice binding settings interface.
Recording Voice Templates
- In the voice binding interface, locate the key to bind
- Click the "Record" button to start recording
- Speak your desired voice command into the microphone (recommended duration: 2-3 seconds)
- Click "Stop" to end recording
- The voice template will be automatically saved and registered
Voice Trigger Modes
The mod supports two voice monitoring modes (configurable):
| Mode |
Description |
| Continuous (ON) |
Automatically monitors microphone when in-game world, pauses when game is paused |
| Key-triggered (OFF) |
Only listens when V key is held |
Configuration
Configuration file path: .minecraft/config/voice_trigger-client.toml
# Similarity threshold (requires exceeding this value for match)
# Range: 0.0 ~ 1.0, default: 0.75
similarityThreshold = 0.75
# Silence detection threshold (dB)
# Default: -43.0
silenceThreshold = -43.0
# Audio buffer size (bytes)
# Range: 1024 ~ 16384, default: 4096
bufferSize = 4096
# Minimum frames required for match
# Range: 1 ~ 16, default: 3
minFramesForMatch = 3
# Continuous monitoring mode
# ON: Continuous microphone monitoring
# OFF: Listens only when V key is held
continuousMonitoring = "ON"
Configuration Tips
- Low recognition rate: Decrease
similarityThreshold (e.g., 0.65)
- Frequent false triggers: Increase
similarityThreshold (e.g., 0.85)
- Short recordings: Increase
minFramesForMatch
- Noisy environment: Raise
silenceThreshold (e.g., -35.0)
Development
Environment Requirements
Clone Project
git clone https://github.com/your-repo/VoiceTrigger.git
cd VoiceTrigger
Build Project
# Windows
gradlew.bat build
# Linux/macOS
./gradlew build
Build artifacts are located in build/libs/.
Run Development Environment
# Launch client
gradlew.bat runClient
# Launch server
gradlew.bat runServer
Generate Language Files
gradlew.bat runData
Technical Architecture
Core Components
| Component |
Description |
VoiceListener |
Real-time voice listener handling microphone input and speech matching |
VoiceRecorder |
Voice recorder for capturing user voice templates |
VoiceProfileManager |
Manages storage and loading of WAV files |
AudioSimilarityDL |
Deep learning audio similarity calculation based on Wav2Vec2 model |
Dependencies
- TarsosDSP: Audio processing and microphone input
- DJL (Deep Java Library): Deep learning inference framework
- PyTorch Engine: Wav2Vec2 model runtime
Voice Profile Storage
Voice templates are stored in: .minecraft/config/voice_trigger/*.wav
File naming format: {key_name}.wav
Key Bindings
| Key |
Function |
B |
Opens voice binding interface |
V |
Voice monitoring (only when continuousMonitoring=OFF) |
FAQ
Q: Voice recognition not working?
- Verify microphone functionality
- Confirm microphone is enabled in game sound settings
- Check
logs/latest.log for error messages
Q: Low recognition rate?
- Re-record clearer voice templates
- Recommended recording duration: 2-3 seconds
- Lower
similarityThreshold value
- Ensure quiet recording environment
Q: Too many false triggers?
- Increase
similarityThreshold value
- Use more distinctive voice commands
- Raise
silenceThreshold to filter background noise
License
Licensed under GNU Lesser General Public License v3.0.
Author
Acknowledgments
评论 0
登录后参与评分
还没有评论,来抢沙发吧