AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Voice Recognition COM
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
TodWulff



Joined: 29 Dec 2007
Posts: 99

PostPosted: Wed Apr 30, 2008 6:41 am    Post subject: Reply with quote

infogulch wrote:
This is really cool, thnx. Very Happy I'll have to get a headset or something so it can understand me better. Razz


I believe that you can train it more and more, in order to help it better understand you. I think you access that thru normal gui dialogs.

Here's to hoping that some speech SDK SME jumps in and answers our queries... Smile
_________________
When replying, please feel free to address me as Tod or t. My AHK.net site...
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2472
Location: Australia, Qld

PostPosted: Sun May 04, 2008 11:52 am    Post subject: Re: Voice Recognition COM Reply with quote

I'm new to the Speech API, but I can at least answer this question:
TodWulff wrote:
How the hell is the script triggered to cause the OnRecognition function to kick off?
COM_ConnectObject connects events exposed by an object to the corresponding functions in script.


If I understand COM_ConnectObject correctly, it works as follows:
    Retrieve an IConnectionPoint interface (pconn) representing the events exposed by the object.

    Construct an object and an IDispatch interface. This object is referred to as an "event sink" (pevent or psink.) RegisterCallback and NumPut are used to construct the interface, with the actual code contained in COM_DispInterface.

    Call pconn->Advise(psink) to create a connection between the connection point and the event sink.

    When the source object raises an event, it calls the Invoke method of our event sink. On the AutoHotkey side, COM_DispInterface is executed with A_EventInfo == 6. RegisterCallback and DllCall are used to dynamically call the appropriate function, based on a script-defined prefix and the name of the event being raised.

Quote:
i.e. what faculties of AHK are you employing to cause this functionality to exist.

In summary:
  • NumGet and DllCall to call methods of COM interfaces.
  • VarSetCapacity, RegisterCallback and NumPut to construct a COM interface.
  • RegisterCallback and DllCall to call a function dynamically.


Edit:
Okay, now I can answer another one. Very Happy
infogulch wrote:
Is there a way to tell it to receive All words SDK recognizes?

Replace everything from COM_Init() to ExitApp with:
Code:
COM_Init()
plistener:= COM_CreateObject("SAPI.SpSharedRecognizer")
pcontext := COM_Invoke(plistener, "CreateRecoContext")
pgrammar := COM_Invoke(pcontext , "CreateGrammar")
COM_Invoke(pgrammar, "DictationSetState", 1)
; No rules to set up!
pevent := COM_ConnectObject(pcontext, "On")
Return

CleanUp:
COM_Release(pevent)
; No rules to clean up!
COM_Release(pgrammar)
COM_Release(pcontext)
COM_Release(plistener)
COM_Term()
ExitApp
Back to top
View user's profile Send private message
75C
Guest





PostPosted: Sun May 04, 2008 1:58 pm    Post subject: Reply with quote

Sean, can you please explain in laymens terms why COM Standard Library of this is recommended over the previous CoHolper version? Smile Is there any major compatibility, performance, or other differentiations? Smile
Back to top
TodWulff



Joined: 29 Dec 2007
Posts: 99

PostPosted: Mon May 05, 2008 5:46 am    Post subject: Re: Voice Recognition COM Reply with quote

Lexikos wrote:
I'm new to the Speech API, but I can at least answer this question:
...

Edit:
Okay, now I can answer another one. Very Happy


Thanks, Lexikos! Wink

-t
_________________
When replying, please feel free to address me as Tod or t. My AHK.net site...
Back to top
View user's profile Send private message
TodWulff



Joined: 29 Dec 2007
Posts: 99

PostPosted: Tue May 06, 2008 1:28 am    Post subject: Re: Voice Recognition COM Reply with quote

TodWulff wrote:
I have been able to get it running and working stand alone reasonably well (I occasionally get the no interface dialog, but I suspect that it is because I am being too impatient (opening a second instance of the script while the first one is releasing it resources, etc.) and confusing the underlying MS framework).


As info, I determined what was causing this issue for me. I was making use of a downloaded version of the COM.ahk wrapper. Once I deleted it, and the associated #include in my scripts, allowing AHK to look in the lib folder for the version included with the latest version of AHK, the no interface issue disappeared.

I post this herein, in the interests of allowing others to learn from my 'mistakes'.

Take care.

-t
_________________
When replying, please feel free to address me as Tod or t. My AHK.net site...
Back to top
View user's profile Send private message
TodWulff



Joined: 29 Dec 2007
Posts: 99

PostPosted: Thu May 08, 2008 4:29 am    Post subject: Reply with quote

Is there a way that the speech api can have it's 'ears' plugged for just a bit? In my IDE app, I am making use of COM TTS as well as the VR functionality.

The damn scripts tend to get into some goofy loops when the app hears itself... Smile

Please advise. Thanks, in advance.

-t
_________________
When replying, please feel free to address me as Tod or t. My AHK.net site...
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2472
Location: Australia, Qld

PostPosted: Thu May 08, 2008 8:30 am    Post subject: Reply with quote

You can either disable the rules you've created or disable speech recognition entirely. You'll probably want to disable speech recognition entirely to avoid triggering some other command or dictation.
Code:
; Disabling a rule:
COM_Invoke(pgrammar, "CmdSetRuleState", "wordsRule", 0) ; 1 to re-enable

; Disabling speech recognition:
COM_Invoke(plistener, "State=", 0)
  ; 1 = active if any rules are active
  ; 2 = always active
Back to top
View user's profile Send private message
TodWulff



Joined: 29 Dec 2007
Posts: 99

PostPosted: Thu May 08, 2008 3:18 pm    Post subject: Reply with quote

Lexikos wrote:
...You'll probably want to disable speech recognition entirely to avoid triggering some other command or dictation...

Yeppers! Thanks Lexikos.

-t
_________________
When replying, please feel free to address me as Tod or t. My AHK.net site...
Back to top
View user's profile Send private message
U90
Guest





PostPosted: Tue May 20, 2008 6:22 pm    Post subject: Reply with quote

Hey, can someone please suggest a rememdy for this problem below?

.... I like this script by Sean allot, but have one gripe (not his fauilt), ... but in Windows Vista, when I run this, ... I am getting that little Ms Listener Voice Recognition widget, that overlays on top of the gui of my application. I'd rather not see this. Can anyone suggest a remedy, and know how to not have that appear, yet have this voice functionality still work? :confused:

Thanks allot!!
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1249

PostPosted: Wed May 21, 2008 3:25 am    Post subject: Reply with quote

U90 wrote:
... but in Windows Vista, when I run this, ... I am getting that little Ms Listener Voice Recognition widget, that overlays on top of the gui of my application. I'd rather not see this. Can anyone suggest a remedy, and know how to not have that appear, yet have this voice functionality still work? :confused:

Unfortunately I can't help you here myself, no access to Vista. I hope other members who can access Vista help you out of the problem.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1249

PostPosted: Fri Jun 13, 2008 3:07 am    Post subject: Reply with quote

I was directed to this post from another post.

infogulch wrote:
It seems to work similar to "OnMessage()", does COM set that up? or is OnRecognition a built-in function by it's own right?
As a matter of fact I mimicked the name OnMessage for OnRecognition. But it looks like add more confusion, regretfully. OnRecognition is more like a callback, and composed of as On + Recognition where On is a custom prefix which can be chosen (by the user) to be any word like Voice_, etc or even an empty string. The voice COM object is aware of and thus callbacks only with the name Recognition, then COM.ahk combines it with the user's chosen prefix On then finally calls the function OnRecognition() if already exist in the script. Notice the line
Code:
pevent := COM_ConnectObject(pcontext, "On")

Quote:
How would I clear words from being recognized anymore?

I don't have much to say on Voice Recognition as I haven't used it myself. I own no facility to use with. But looking through the documentation, seems to be able to do it by creating another ISpeechGrammarRuleState (say pstate1) which will remain inactive, then transit the word(s) you want to disable to it from the current active pstate. E.g.,
Code:
COM_Invoke(pstate, "AddWordTransition", "+" . pstate1, "One Two Three")
or
Code:
COM_Invoke(pstate, "AddWordTransition", "+" . pstate1, "One|Two|Three", "|")


Quote:
Is there a way to tell it to receive All words SDK recognizes?
Again according to the documentation, seem to be able to use (maybe in conjunction with DictationLoad and/or DictationUnload)
Code:
COM_Invoke(pgrammar, "DictationSetState", 1)

Refer this
Code:
Enum SpeechRuleState
    SGDSInactive = 0
    SGDSActive = 1
    SGDSActiveWithAutoPause = 3
    SGDSActiveUserDelimited = 4
End Enum


PS. Well, I now noticed that this post has another page. If want to control them in entirety, read the posts by Lexikos.
Back to top
View user's profile Send private message
infogulch



Joined: 27 Mar 2008
Posts: 103
Location: KC, MO

PostPosted: Fri Jun 13, 2008 2:25 pm    Post subject: Reply with quote

Thank you Sean and Lexikos! That clears some stuff up for me. Even helps me understand the COM.ahk lib better. Smile I'll have to take a closer look at the sdk documentation, I think it was way over my head when I posted before. (who am i kidding? still is.. Laughing )
Thanks again for your replies!
_________________
Back to top
View user's profile Send private message
U90
Guest





PostPosted: Sun Jul 06, 2008 3:20 pm    Post subject: Reply with quote

Hey, just curious, is anyone aware of a way to get rid of the annoying voice-bar GUI widget that appears over my apps, on Windows Vista+, when invoking voice? Smile
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group