语音控制的宏和快捷键。
项目描述
voice-commander
一个使用语音命令和快捷键定义宏和触发器的应用程序。受流行的商业软件VoiceAttack的启发。
需要Python 3.12+
这是对现有项目的重大重写。如果您正在寻找此软件的旧版本,请查看pre-rewrite标签(或在PyPI上现在已撤回的0.0.1a
版本)。
安装
通过pip
要安装,最好在virtualenv中,使用pip
pip install voice-commander
此软件还要求您安装AutoHotkey。您可以将AutoHotkey安装到默认位置,或者,作为替代方案,在virtualenv中安装ahk-binary
软件包
pip install ahk-binary
Windows可执行文件
即将推出。
用法
基本原语包括<强>配置文件强>、<强>触发器强>、<强>动作强>和<强>条件强>。
- 一个<强>动作强>定义了触发时将执行的基本操作,例如按下键盘键、播放声音、打开程序等。
- 触发器用于触发一组相关的操作。例如,说出语音激活短语、按下一个热键组合(如win+n)或类似操作。触发器可以触发任意数量的操作。
- 条件用于有条件地控制触发器或触发器内的特定操作的执行。例如,你可能只想在打开/聚焦特定窗口(如游戏)时,才执行按键操作。触发器可以附加到触发器或操作上。
- 配置文件是一组触发器(及其相关的操作/条件),可以方便地一起激活/停用。
基本示例
您可以在Python代码中定义和运行配置文件。
from voice_commander.profile import Profile
from voice_commander.triggers import *
from voice_commander.actions import *
profile = Profile("myprofile")
# triggers when any of these phrases are spoken
# You can add as many phrases as you want
trigger = VoiceTrigger('lower landing gear', 'retract landing gear')
# When the above trigger activates from a voice command, presses the "l" button (bound in-game to landing gear toggle)
action = AHKPressAction("l")
trigger.add_action(action) # you can add multiple actions if you want. Here, we're just adding one action.
profile.add_trigger(trigger)
profile.run()
您还可以将配置文件序列化/反序列化到/从JSON。
# save the profile to the present working directory
profile.save_json(dirname='.', filename='myprofile.vcp.json') # "vcp" means "Voice Commander Profile"
from voice_commander.profile import load_profile
# easily load profiles from JSON
profile = load_profile('./myprofile.vcp.json')
profile.run()
您还可以直接编辑和运行表示完整配置文件的JSON文件。上述示例生成的JSON文件大致如下
{
"configuration": {
"profile_name": "myprofile",
"schema_version": "0",
"triggers": [
{
"trigger_type": "voice_commander.triggers.VoiceTrigger",
"trigger_config": {
"*trigger_phrases": [
"lower landing gear",
"retract landing gear"
]
},
"actions": [
{
"action_type": "voice_commander.actions.AHKPressAction",
"action_config": {
"key": "l"
}
}
]
}
]
}
}
还支持JSON5。未来可能会支持更多格式。
您可以直接从命令行运行这些文件中的配置文件
python -m voice_commander run-profile --profile-file ./myprofile.vcp.json
完整文档即将推出。
扩展语音指挥官
语音指挥官的开发考虑了扩展性。目前我们还没有太多可以分享的内容,但您可以查看voice-commander-elite项目,这是一个旨在为《危险边缘》游戏玩家提供特殊功能的扩展。它目前正在作为未来扩展的实验对象。《voice-commander-elite》也可能给您提供其他可能扩展的想法。
状态
该项目处于早期开发阶段,但已准备好使用。将努力保持现有配置文件架构与(或转换为)任何未来架构版本的兼容性,尽管Python API可能会进行一些破坏性更改,至少在我们起步时是这样的。
当前限制
该软件的一些显著限制如下
- 只能读取游戏手柄控制器的X、Y、Z、R、U和V轴。一些特殊的轴(如某些油门控制器的“旋钮”)不能用作触发器
- 虽然可以使用控制器/游戏手柄输入进行触发宏,但我们目前还不支持在宏中发送控制器或游戏手柄输入。因此,您可能需要确保有键盘绑定可用于游戏中的操作。
- 当前仅支持波形音频文件(.wav)播放声音(且仅在Windows上支持)
- 尚未支持XInput设备(例如,Xbox One控制器)用于触发或发送
- 大多数有意义的功能需要
ahk
(因此还需要AutoHotkey和Windows)。未来的版本将支持Linux友好的替代方案 - 不支持游戏手柄/控制器输入的输入拦截(阻止活动程序接收输入)。
项目详情
下载文件
下载适合您平台的文件。如果您不确定该选择哪个,请了解更多关于安装包的信息。
源分布
voice_commander-0.0.3.tar.gz (22.3 kB 查看哈希)
构建发行版
voice_commander-0.0.3-py3-none-any.whl (24.4 kB 查看哈希值)
关闭
voice_commander-0.0.3.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 2414f32cfdcfd145920d3aa39436310038f46460e06092f8ca7d992d4bc8463b |
|
MD5 | d3c9b0955e2c26d7ce05f5ada034d68c |
|
BLAKE2b-256 | 7eeba256d319eff4ce1d66cca8ade270a727dc09a798ae439615057906022187 |
关闭
voice_commander-0.0.3-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d3e65890c81864dbed692c20012aa52900355e3bd43056bbd3dbbc9bf0d8f3c8 |
|
MD5 | 87e96ee5f212a26b20a419b649dca577 |
|
BLAKE2b-256 | ff8f1e0af9e77d2f14e35ec7f355cf054e5fe8fee9de1fd29dd00a11bc52bb2c |