Use your voice as a Hotkey in AutoHotkey!
If you speak a language other than English, I would greatly appreciate it if you could help expand the demo or suggest other changes!
- Install the Microsoft Speech Platform Runtime
You will need either x86 or x64, depending on what version of AHK you run. No harm in installing both, just to be sure. - Install at least one Language Pack
Speech recognition packs will haveSR
in their name.TTS
labelled downloads are for Text-to-speech and will not work with HotVoice.
egMSSpeech_SR_en-US_TELE.msi
Note that while Windows 7 is technically supported, language packs may fail to properly load. See here - Download a release of HotVoice from the Releases Page and unzip it to a folder of your choice (This shall be referred to as the "HotVoice folder" from now on).
DO NOT use the "Clone or Download" button on the main GitHub page, this is for developers. - Ensure the DLLs that are in the HotVoice Folder are not blocked.
Right-clickunblock.ps1
in the HotVoice Folder and select "Run as Administrator". - Run the Demo script and make sure it works for you.
It should look something like this:
"Recognizers" are basically Language Packs. Ordering seems to be based on installation order, with the "Lightweight" pack always present and at the end of the list. Therefore, if you only install one language pack, it should always be ID 0
, so everything in HotVoice defaults to using ID 0.
The Mic Volume
slider should move when you speak.
HotVoice uses the "Default Recording Device" that is configured in Windows.
HotVoice uses these two types of object to build up commands.
Throughout this documentation, the following syntax will be used to denote a phrase with optional components:
Launch [Notepad, Word]
In this instance it can mean "Launch Notepad" or "Launch Word".
Choices objects represent a series of optional words. As in the above example, [Notepad, Word]
is a series of Choices.
Grammar objects are the primary building blocks of HotVoice. They can hold either single words, or choices objects, or even other Grammar objects.
A HotVoice script must do the following:
-
Load the HotVoice Library
#include Lib\HotVoice.ahk
-
Create a new HotVoice class
hv := new HotVoice()
- Add at least one Grammar
; Create a new Grammar
testGrammar := hv.NewGrammar()
; Add the word "Test" to it
testGrammar.AppendString("Test")
; Load the Grammar
hv.LoadGrammar(testGrammar, "Test", Func("MyFunc"))
- Start the Recognizer
hv.StartRecognizer()
Creates a new Choices object from a comma-separated string
Choices NewChoices(string choiceListStr)
eg choices := hv.NewChoices("Up, Down, Left, Right")
Note that if you want to re-use the same choices in multiple scripts, see MikeHotelOscar's ChoiceBuilder library
Creates a new, empty Grammar Object
GrammarObj NewGrammar()
eg grammarObj := hv.NewGrammar()
Gets a Choices object from HotVoice's store of choices objects.
By default, this is empty execpt for the Percent
Choices object, which contains the numbers 0-100
Choices GetChoices(string name)
eg percentChoices := hv.GetChoices("Percent")
Adds a Choices object to HotVoice's store of choices objects.
void SetChoices(string name, Choices choices)
eg percentChoices := hv.SetChoices("Directions", hv.NewChoices("Up, Down, Left, Right"))
Loads a GrammarObject into the Recognizer and specifies which function to call when it is triggered.
void LoadGrammar(GrammarObject g, string name, BoundFunc callback)
eg hv.LoadGrammar(testGrammar, "Test", Func("MyFunc"))
Gets a list of available recognizers
RecognizerObject GetRecognizerList()
eg recgonizers := recognizers := hv.GetRecognizerList()
RecognizerObject is an array containing objects with the following properties:
ID: The ID of the recognizer (Starts at 0)
Name: The Name of the recognizer
TwoLetterISOLanguageName: The ISO 639-1 code for the language (eg "en")
LanguageDisplayName: The display name for the language (eg "English (United States)")
Loads a Recognizer
void Initialize(int recognizerId = 0)
eg hv.Initialize()
Note that if you call Initialize
, any previously loaded recognizer is unloaded.
Starts the Recognizer
void StartRecognizer()
eg hv.StartRecognizer()
Gets a human-readable string that describes the phrasology that this Grammar supports
string GetPhrases()
eg phrases := grammarObj.GetPhrases()
Adds a word or words to a GrammarObject
void AppendString(string text)
eg grammarObj.AppendString("Hello")
Adds a ChoicesObject to this GrammarObject
void AppendChoices(Choices choices)
eg grammarObj.AppendChoices(choicesObj)
Adds up to 10 GrammarObjects to this GrammarObject
void AppendGrammars(GrammarObject g1, ... , GrammarObject g10)
eg grammarObj1.AppendGrammars(grammarObj2, grammarObj3)
This ONLY APPLIES if you want to work with the C# code that powers HotVoice.
If you are writing AHK scripts using HotVoice, this does not apply to you.
- Install the Microsoft Speech Platform SDK 11.
- When you open the SLN, you may need to fix the reference to
Microsoft.Speech
It can be found inC:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly