Page 3 of 7

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 02 Jun 2018, 11:31
by burque505
I tried the CultureOptimize DLL, getting this error still:
[deleted]
EDIT: Error gone, so I deleted it. I restarted, and all was well.
I really appreciate you taking the time and effort for this, by the way, thanks.
Just a note: It appears the ID number is related to the order in which recognizers are installed. I installed German first, English second, Spanish third (for whatever reason).
Here's how the IDs show up:
IDs.PNG
IDs.PNG (4.72 KiB) Viewed 5544 times
Regards,
burque505

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 02 Jun 2018, 12:13
by evilC
No problem
So that last DLL made a difference?
If you had to take special steps to get it to work on Win7, if you could summarize them so I could update the docs, that would be great.

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 02 Jun 2018, 12:42
by burque505
Here's what I did to get HotVoice working on my Win7 SP1 64-bit machine:
1) In general, I followed the instructions on this page.
2) First, I downloaded and installed the 64-bit Version 11 Speech Platform runtime from here.
3) Second, I downloaded and installed the 64-bit Version 11 Speech Platform SDK from here.
4) Third, I downloaded and installed several Version 11 languages from here.
I also switched out the included HotVoice.dll for the CultureOptimize.zip version evilC provided above. I'm not sure if this step was required or not, but it certainly did not hurt.
The ID number of the installed language appears to be determined by installation order, and not by the default language of my OS. I installed German first, English second, and Spanish third (although I had intended to install English first, I clicked on the wrong installer). The IDs display as below:
IDs.PNG
IDs.PNG (4.72 KiB) Viewed 5536 times
To my surprise, recognition works in English for the Demo.ahk script using all four of the recognizers shown, including the Microsoft Lightweight Speech Recognizer.

Here is a test script based on Simple Example.ahk, which works for me:

Code: Select all

; Simple German example
; Test of German recognition
; This script demonstrates a single initial word ("Bundesrepublik")

#SingleInstance force
#Persistent ; You will need this if your script creates no hotkeys or has no GUI

; 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("Bundesrepublik")

; Load the Grammar
hv.LoadGrammar(testGrammar, "Bundesrepublik", Func("MyFunc"))

hv.StartRecognizer()

return

MyFunc(grammarName, words){
	ToolTip % "Command: " grammarName " was triggered @ " A_TickCount " with " words.Length() " words"
}
Note the ID in the script needed to match the ID for the recognizer. In the following script it's changed to '2' for Spanish:

Code: Select all

; Test of Spanish recognition
; This script demonstrates a phrase("Me gustaría ir a la playa")

#SingleInstance force
#Persistent ; You will need this if your script creates no hotkeys or has no GUI

; 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(2)

; Create a new Grammar
testGrammar := hv.NewGrammar()

; Add the word "Test" to it
testGrammar.AppendString("Me gustaría ir a la playa")

; Load the Grammar
hv.LoadGrammar(testGrammar, "Me gustaría ir a la playa", Func("MyFunc"))

hv.StartRecognizer()

return

MyFunc(grammarName, words){
	ToolTip % "Command: " grammarName " was triggered @ " A_TickCount " with " words.Length() " words"
}
English, German and Spanish all work with the simple examples.

Regards,
burque505

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 02 Jun 2018, 12:55
by evilC
Hmm, is Speech Recognition easier to process in German, what with you guys munging words together like that?
Thanks for the list - so it appears that you did not need any of the things outside of stuff that I had linked, but maybe some of the things that I marked as either/or bitness-wise, you actually needed both?
If the CultureOptimize version does not break anything, I think I will commit it then, as it seems a lot more sensible

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 02 Jun 2018, 12:59
by burque505
:) Well, English is my native language, so I'm probably hammering both German and Spanish, but they both work.
In my case, I'm not sure whether some of what I did was optional. But the CultureOptimize version definitely did not break anything for me.

Here's another example in German based on Choices.ahk:

Code: Select all

; This script demonstrates a single initial word ("Testen"), followed by a choice of "rauf", "runter", "links" or "rechts"

#SingleInstance force
#Persistent ; You will need this if your script creates no hotkeys or has no GUI

; 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("Testen")

; Create a new Choices object with four direction choices
directionChoices := hv.NewChoices("rauf, runter, links, rechts")

; Add the direction choices to the Grammar
testGrammar.AppendChoices(directionChoices)

; Load the Grammar
hv.LoadGrammar(testGrammar, "Testen", Func("MyFunc"))

hv.StartRecognizer()

return

MyFunc(grammarName, words){
	ToolTip % "Command: " grammarName " " words[2]
}

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 02 Jun 2018, 13:22
by evilC
Maybe what we should do is instead of use an ID number, use the name of the Culture?

ie, it could maybe be hv.Initialize("DE") or whatever.
I wonder if multiple recognizers can co-exist for different languages?

I suppose I could just add a method to try and find, for example, a german language recognizer and return it's ID.
Then scripts which are inherently german could use this method to get an appropriate ID.

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 02 Jun 2018, 13:38
by burque505
Maybe so, seeing as the ID _seems_ to be based on installation order of languages. To tell you the truth, I haven't tried any of these scripts leaving the ID at 0 to see if they'll work with all languages, but I will, and I'll edit this post.

EDIT: The ID does definitely make a difference for recognition, although some words get recognized regardless of which ID I choose. Matching the ID to the target language is definitely better.
By the way, for the benefit of those just joining us :) here's a script which runs Firefox, Word, Excel or Outlook, depending on whether you say "Run Firefox", "Run Word", "Run Excel" or "Run Outlook".

EDITED EDIT: NOT WORKING in a fashion. I have to say "Run Winword", "Run Excel", "Run Firefox", or "Run Excel", but so far it seems accurate.
Spoiler
Edit: Glitch. TStill tinkering, but this works.

Regards,
burque505

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 05 Jul 2018, 17:41
by ArchCrunch
Hi,

Is this working on Windows 10? I am not getting any errors, but the demo doesn't seem to respond at all. The only thing is that the volume is moving a bit when sound occurs, but the text box below appears empty.

Any ideas?

Thanks

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 06 Jul 2018, 03:57
by evilC
Yup, was developed on Win10
If the volume slider is moving, that's a good sign.
What recognizer are you using?

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 08 Jul 2018, 08:09
by ArchCrunch
Hi, It worked! I think I was not as loud as I should have been. It is not working 100% of the time though. Is there a way to print what the mic is actually understanding?

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 09 Jul 2018, 07:31
by evilC
It can be debugged via the API, but HotVoice does not display it until it is recognized.
How high is the slider moving when you speak? If it is not getting much volume, it might not be that reliable.
I find that with most mics, I need to crank the input level to full and/or enable "Mic Boost".

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 12 Jul 2018, 14:18
by atxbilly
I used HotVoice to create a safe word for Path of Exile. Now, when I say, "Bears", it checks to see the game is running and closes it before the bears kill me. I also use it to cast spells hands free. Thanks for the great project!

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 28 Aug 2018, 17:07
by PGilm
I'm getting the DLLs in the HotVoice Folder are blocked message and have run the powershell command in the lib folder (where the dlls are) and the parent, where Demo.ahk is. Is there a trick for using with Win 8.1 I'm on? I'm more or less following the Win 7 instructions with no luck.

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 29 Aug 2018, 04:26
by evilC
Are you running it as admin?
Failing that, try right-clicking the DLLs and select properties, see if there is anything in that dialog that allows you to unblock.

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 29 Aug 2018, 14:47
by PGilm
Yup, cmd as admin then into ps did it . . . Thx! Great work. I was tapping into the WSR engine for my earlier efforts with less success. Was I using the lightweight recognizer there?

BTW, is there a typo in line 21 of hv.ahk? "nanme" for "name"? Fixing it seems to not break anything. :)

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 09 Dec 2018, 17:15
by ghostyzx
Awesome library!

I'm trying to find a way to run it nonstop, that means I need to pause the voice recognition from time to time, I need to be able to manually stop&restart the voice recognition (noise in the room, video playing, etc). Right there's only the method StartRecognizer to start things, woudn't be possible to implement also something like StopRecognizer?

Possible workarounds for now are the following:
1) have code in each triggered function that checks if we should be in a "paused" state and ignore the recognitions
2) have the voice recognition code in a separate ahk script and start/stop it on demand

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 10 Dec 2018, 05:49
by evilC
Is a trivial addition. Will add once I get a moment. Have raised an issue to remind me.
https://github.com/evilC/HotVoice/issues/2

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 11 Dec 2018, 11:22
by r2997790
I've been meaning to revisit this speech recognition stuff for ages. Wonderful work @evil_c

I was wondering if you, or someone else could help me understand how to adapt the code to do the following...

Activation word / word listened for ("Test", in the demo you included with the script)

... but then... I'd like to feed it a string, rather than a single word, like the up, down, left, right -- in your example.

Something like this....

Simon (activated)

"Open Microsoft Word" < it would capture and interpret a string rather than a single word.

That would open the opportunity for...

Open Word
Open Excel
Close Word
Close Excel

etc. opens up a lot of opprtunities if it can interpret a string of characters.

I tried adding strings to hv.NewChoices but without success.

Does anyone have an idea of how to do it? Thanks!

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 11 Dec 2018, 13:22
by evilC
This library does not support recognition of arbitrary words - you need to give it a list of all possible application names in order to support this.

See how the demo code implements the "call name on their phone" example

Re: HotVoice - Speech Recognition + Volume detection for AHK (C# DLL)

Posted: 11 Dec 2018, 14:08
by evilC
Version 0.1.3 released - implemented ghostyzx's request

https://github.com/evilC/HotVoice/releases/tag/v0.1.3

Code: Select all

### Added
- Add StopRecognizer() endpoint