; Load the HotVoice Library
#include Lib\HotVoice.ahk
; Create a new HotVoice class
hv := new HotVoice()
; Initialize HotVoice and tell it what ID Recognizer to use
hv.Initialize(0)
; 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"))
hv.StartRecognizer()
return
MyFunc(grammarName, words){
ToolTip % "Command: " grammarName " was triggered @ " A_TickCount " with " words.Length() " words"
}
Yeah, there are a LOT of things which need to be installed for this to work, I need to work out exactly what is required. Will try and take a look at it this weekend
I did some more work on this tonight, and thanks to Cap'n Odin for helping test
Improved logging and stuff, better demo
It seems that all you need to install is the x86 / x64 (Match to what version of AHK you have installed, or just install both) Runtime
Plus one language pack (eg MSSpeech_SR_en-US_TELE.msi)
HotVoice 0.0.3 has now been released on GitHub: https://github.com/evilC/HotVoice
I started off the documentation, added a basic example, but otherwise it is identical to 0.0.2
Thanks for sharing this. Pretty fun to play around with and useful as well.
I did notice that the last version makes two-worded triggers throw an error (due to the choices I guess) :
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at HotVoice.Recognizer_SpeechRecognized(Object sender, SpeechRecognizedEventArgs e)
at Microsoft.Speech.Recognition.SpeechRecognitionEngine.SpeechRecognizedProxy(Object sender, SpeechRecognizedEventArgs e)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at Microsoft.Speech.Internal.AsyncWorkItem.Invoke()
at Microsoft.Speech.Internal.AsyncSerializedWorker.WorkerProc(Object ignored)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(
Is there any way to use both ?
.SubscribeWord with two-worded commands and .SubscribeWordWithChoiceList
@SpecialGuest if you put a hyphen between two-words, it seems to count as one
I have learned a ton since I did the first version, what I am working on now does not suffer from the same problem.
The whole project is in a high state of flux at the moment, trying to work out how to provide max flexibility but also not force too much complexity on the user - not sure how long those old methods will last and if it is worth going back and fixing them...
A hyphen works indeed Thanks and keep up the good work. It looks promising.
I'll be sure to test that new version too later on as well but first I'm trying a few things with the "old" version.
Tinkering around today, I think I have hit upon a solution which is simpler - that whole "GrammarVar" system just did not quite gel for me.
Unfortunately, COM does not seem to support variable number of parameters in a function call, but I am experimenting with the idea of 10 parameter functions with optional parameters as a work-around.
This allows you to work in AHK with objects, build them up using AHK variables, and then load the finished result into the recognizer.
I am not sure you are gonna be wanting to add more than 10 grammar branches in a node, and we can always maybe add more.
This would not affect Choices - you can add a choice list of arbitrary length.
Version 0.1.0 has now been released. https://github.com/evilC/HotVoice/releases/tag/v0.1.0
Syntax has completely changed - there are a few more steps involved now for a basic setup, but the power and flexibility of it increased massively.
I hope I struck the right balance.
I could maybe re-add equivalents to the old methods to enable simple one-line additions though
Hi, I get this error and the PowerShell command doesn't cure it. I tried running it in the script folder and the lib folder.
EDIT: AHK_L 1.1.28.02 U64, Win7 SP1 64-bit
EDIT: I had long ago changed references to "null" in CLR.ahk to "nulo" for the same reason you mention in the script, AHK_H compatibility. I commented out the CLR section in the script and referenced my own lib, but got the same result (which seems only logical).
---------------------------
Demo.ahk
---------------------------
HotVoice.dll failed to load
Dll may be blocked. Try running the powershell command
Get-ChildItem -Path '.' -Recurse | Unblock-File
in the script folder
---------------------------
OK
---------------------------