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

Post your working scripts, libraries and tools
User avatar
gregster
Posts: 1422
Joined: 30 Sep 2013, 06:48

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

28 May 2018, 02:47

They all seem to work on my Win10 64 bit with AHK 1.1.28.02 U64 :thumbup: Demo works. I will have to play around with it later.
burque505
Posts: 626
Joined: 22 Jan 2017, 19:37

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

28 May 2018, 07:42

Thanks, gregster. I bet it's me running Win7. I found this article on speech recognition, by the way.
EDIT: I downloaded the MS Speech SDK 11.0 and compiled HotVoice.0.1.0 (VS2017). It compiled fine, but the test app crashed, throwing a System.Runtime.InteropServices.COM unhandled exception.
Class ID (hope I'm copying it correctly): CLSID {49428A60-C997-4D0E-9808-9E32C178D58}, error 80040154 (Class not registered). I'm going to restart, try regasm on the assembly.
Regards,
burque505
User avatar
evilC
Posts: 4354
Joined: 27 Feb 2014, 12:30

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

28 May 2018, 10:24

Yeah, I dunno if Win7 is supported or not.
Thanks for the link to the article, it may help to link it for people as it explains what Grammars and Choices are quite well.

FYI, In HotVoice, the "GrammarObject" (The HotGrammar class that you get when you do hv.NewGrammar()) is a wrapper around the GrammarBuilder class.
The Choices class in HotVoice is not wrapped. When you do hv.NewChoices(), you get an actual Choices class back.
There is no user-exposed Grammar object in HotVoice, seeing as we need to convert the GrammarBuilder into a Grammar to load it and there doesn't seem to be any point in having access to the Grammar class that got uploaded.
r2997790
Posts: 24
Joined: 02 Feb 2017, 02:46

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

01 Jun 2018, 05:59

This is going to be an awesome script to try... Thank you so much for making it.... I've dabbled in voice recognition before and found file commands have been super fast.

I'm trying to locate hotvoice.dll -- it didn't seem to download / install with any packages as per the install instructions. Could someone please help me figure out where it's gone / where to find it?

Many thanks
R
User avatar
gregster
Posts: 1422
Joined: 30 Sep 2013, 06:48

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

01 Jun 2018, 06:39

I'm trying to locate hotvoice.dll -- it didn't seem to download / install with any packages as per the install instructions. Could someone please help me figure out where it's gone / where to find it?
It is included in the packages from the release branch: https://github.com/evilC/HotVoice/releases - just tested, I found the dll in the Lib folder of Hotvoice.zip
r2997790
Posts: 24
Joined: 02 Feb 2017, 02:46

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

01 Jun 2018, 07:07

Thanks @gregster @evil ... I downloaded the source zip I think and it wasn't there but just downloaded the Hotvoice.zip file on the Releases and all is good

Many thanks for your help... can't wait to try it out now!
r2997790
Posts: 24
Joined: 02 Feb 2017, 02:46

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

02 Jun 2018, 03:17

Seems like the DLL issue has been resolved (and by installing the 64Bit version of the Speech engine).

But now I am getting this issue: Image

A language issue despite downloading a ton of the .msi language files.

Frustrating... anyone else had this issue and know how to fix it?

Many thanks.
User avatar
gregster
Posts: 1422
Joined: 30 Sep 2013, 06:48

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

02 Jun 2018, 07:07

With the 0.1.0 version I also get this error message, if I set the recognizer id to 1 (which would be the second language I installed).
Setting it to 2 ('lightweight' in this case) doesn't crash, but doesn't recognize anything (but that was expected).

With the older versions 0.0.3 and 0.0.4, setting the id to 1 doesn't create an error, but doesn't recognize anything either. The volume level doesn't even move.

All three versions seem to work only with the recognizer id set to 0, although two language packs are installed.

Perhaps there is something still hardcoded to 0 in the dll?

Btw, there seems to be a typo in

Code: Select all

LoadGrammar(grammar, name, callback){
		if (this._grammarCallbacks.HasKey(name)){		; was: if (this._grammarCallbacks.HasKey(nanme)){
But that shouldn't cause the problem mentioned above...

Edit: There is another minor bug in Initialize(id) - the check for a valid id isn't working in all cases, because id is zero-based. I think this should fix it:

Code: Select all

Initialize(id){
		c := this.Instance.GetRecognizerCount() - 1 
		if (id > c){
			MsgBox % "No Such ID " id
User avatar
evilC
Posts: 4354
Joined: 27 Feb 2014, 12:30

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

02 Jun 2018, 09:15

@r2997790 - Try removing all but one language pack?

@gregster Yeah, I suspect that only English works, as I tried installing French and Spanish, but could not get them to recognize anything I said.
It could just be that only recognizer 0 works, I dunno. If anyone could shed any light on it, that would be great.

Thanks for the Initialize fix - it was also outputting c, not id - duh!
burque505
Posts: 626
Joined: 22 Jan 2017, 19:37

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

02 Jun 2018, 09:32

@evilC, I think you have to have a CultureInfo object for each language. I found this code snippet in the article linked above.

Code: Select all

CultureInfo ci = new CultureInfo("en-us");
sre = new SpeechRecognitionEngine(ci);
sre.SetInputToDefaultAudioDevice();
sre.SpeechRecognized += sre_SpeechRecognized;
Regards,
burque505
User avatar
gregster
Posts: 1422
Joined: 30 Sep 2013, 06:48

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

02 Jun 2018, 09:49

Actually, it doesn't seem to be a question of language, but only of id.

I have german on id 0 and it understands it quite well. Even using the original english words - with (awful sounding) german pronunciation - worked... :mrgreen: while english pronunciation didn't work then. Trying to use US english on id 1 would throw the error above.

But perhaps only the standard language of the specific windows installation works (by default?)...?!? I also use german as standard language for my windows installation. That might be connected to this CultureInfo object.
User avatar
gregster
Posts: 1422
Joined: 30 Sep 2013, 06:48

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

02 Jun 2018, 10:45

Looks good so far. German on id 0, and US English on id 1 work here now.
Thanks a lot!
burque505
Posts: 626
Joined: 22 Jan 2017, 19:37

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

02 Jun 2018, 10:52

Wish I could test it :(
Still haven't gotten it to run on Win7.
EDIT: Downloaded the SpeechPlatform runtime from here and installed it.
Still throwing an error, but at least the DLL loads. I will uninstall and reinstall the SDK and post results.
EDIT: Reinstalled SDK, both it and runtime now 64-bit. Still get the CultureInfo.InvariantCulture error.
Error is this:
Spoiler
Reinstalled English and German due to 'CultureInfo.InvariantCulture' error, now getting this error:
Spoiler
Regards,
burque505
Last edited by burque505 on 02 Jun 2018, 11:25, edited 1 time in total.
User avatar
evilC
Posts: 4354
Joined: 27 Feb 2014, 12:30

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

02 Jun 2018, 11:21

It seems like the language pack you have is of type CultureInfo.InvariantCulture ?
I was following the advice here - https://stackoverflow.com/questions/246 ... -recognize
So basically I take the culture from the language pack and pass it to the constructor of the recognizer

Code: Select all

        public HotVoice()
        {
            _recognizers = SpeechRecognitionEngine.InstalledRecognizers().ToList();
            var percentileChoices = new Choices();
            for (var i = 0; i <= 100; i++)
                percentileChoices.Add(i.ToString());
            _choicesDictionary.Add("Percent", percentileChoices);
        }

        public void Initialize(int recognizerId = 0)
        {
            AssertRecognizerExists(recognizerId);

            _recognizer = new SpeechRecognitionEngine(new CultureInfo(_recognizers[recognizerId].Culture.Name));

            // Add a handler for the speech recognized event.
            _recognizer.SpeechRecognized += Recognizer_SpeechRecognized;

            // Configure the input to the speech recognizer.
            _recognizer.SetInputToDefaultAudioDevice();
        }

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Haswell, hughman, nilsonrdg, Sabestian Caine, Terka and 42 guests