AutoHotkey Community

It is currently May 27th, 2012, 10:37 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 129 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9
Author Message
 Post subject:
PostPosted: June 24th, 2011, 6:31 pm 
Hi,

i testet the script at page 6 and it works fine.
Is there a way to change it so that it recognize german words ?

Greetings Lirave


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 15th, 2011, 6:07 am 
Sean wrote:
As I said, to use SpInProcRecognizer you have to explicitly claim the (non-trivial) audio input device. I recently added the code to claim it, but didn't add the code to obtain it as I didn't want to encourage using SpInProcRecognizer which would incur another several posts why it causes this or that. As no one posted any other workarounds in Vista, however, there seems to be no choice. To obtain the default audio input device, use
Code:
paudioin := COM_Invoke(paudioinputs:=COM_Invoke(plistener, "GetAudioInputs"), "Item", 0), COM_Release(paudioinputs)
; COM_Release(paudioin) ; add this in an appropriate place!
before
Code:
COM_Invoke(plistener, "AudioInput", paudioin ? "+" . paudioin : "+0")

BTW, not tested.


I know I'm digging up an old post, but I have spent hours now trying to fix this by referencing MSDN.

I am on Windows 7 SP1 and when I try this I get the following error:

Function Name: "AudioInput"
ERROR: (0x80045001)
PROG:
DESC:
HELP: ,0

ERROR2: Type Mismatch.
(0x80020005)

Will Continue?



If I apply the line:

Code:
MsgBox % COM_Invoke(paudioin, "GetDescription")


I get the following result:
Microphone (Realtek High Definition Audio)

If I apply this line, however:

Code:
MsgBox % paudioin


The following result is a blank Message Box.

I am not sure what I am doing wrong. Below is the exact code I am looking at:

Code:
#Persistent
OnExit, CleanUp

COM_Init()
plistener:= COM_CreateObject("SAPI.SpInProcRecognizer")

;plistener:= COM_CreateObject("SAPI.SpSharedRecognizer")
paudioin := COM_Invoke(paudioinputs:=COM_Invoke(plistener, "GetAudioInputs"), "Item", 0), COM_Release(paudioinputs)

MsgBox % COM_Invoke(paudioin, "GetDescription")

COM_Invoke(plistener, "AudioInput", (paudioin) ? "+" . paudioin : "+0")
pcontext := COM_Invoke(plistener, "CreateRecoContext")
pgrammar := COM_Invoke(pcontext , "CreateGrammar")
COM_Invoke(pgrammar, "DictationSetState", 1)
prules := COM_Invoke(pgrammar, "Rules")
prulec := COM_Invoke(prules, "Add", "wordsRule", 0x1|0x20)
COM_Invoke(prulec, "Clear")
pstate := COM_Invoke(prulec, "InitialState")

; Add here the words to be recognized!
COM_Invoke(pstate, "AddWordTransition", "+" . 0, "Computer")
COM_Invoke(pstate, "AddWordTransition", "+" . 0, "Two")
COM_Invoke(pstate, "AddWordTransition", "+" . 0, "Three")
;;

;COM_Invoke(prules, "Commit")
;COM_Invoke(pgrammar, "CmdSetRuleState", "wordsRule", 1)
;COM_Invoke(prules, "Commit")
pevent := COM_ConnectObject(pcontext, "On")
Return

CleanUp:
COM_Release(paudioin)
COM_Release(pevent)
;COM_Release(pstate)
;COM_Release(prulec)
;COM_Release(prules)
;COM_Release(pgrammar)
COM_Release(pcontext)
COM_Release(plistener)
COM_Term()
ExitApp

OnRecognition(prms, this)
{
   presult := COM_DispGetParam(prms, 3, 9)
   pphrase := COM_Invoke(presult, "PhraseInfo")
   sText   := COM_Invoke(pphrase, "GetText")
   COM_Release(pphrase)
;   Add custom operations from here!
   if IsLabel(sText)
   GoSub, %sText%
}

Computer:
MsgBox, You Said Computer
return
#Include COM.ahk


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 18th, 2011, 8:49 pm 
Offline

Joined: June 11th, 2010, 2:24 am
Posts: 78
Playing around with this... Confirmed the test above for Win7 32 bit- COM_Invoke(plistener, "AudioInput", paudioin ? "+" . paudioin : "+0") crashes if SR is open already

Question: Is there a way to switch off all SR contexts other than the one I am setting here? As I am playing with my script, windows tries to do all kinds of things in the background when I am slightly off with my pronunciation (I guess when it's not recognized for AHK it's handed to windows?)

_________________
Paddy For Lightroom!
Use AHK for keyboard mapping, Midi support, external keyboards, and more in Adobe Lightroom


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2011, 2:25 pm 
Offline

Joined: June 11th, 2010, 2:24 am
Posts: 78
Used it for my application as an experiment. Picture editing and tagging with voice commands in Adobe Lightroom. Video here: http://www.youtube.com/watch?v=sVjmZMLrF_Y

Code as discussed above, pretty straight foward, thanks!

I need to now figure out how to cleanly shut it down, add words, and start again. (at the moment, I brutally start the script again when the user added words)

_________________
Paddy For Lightroom!
Use AHK for keyboard mapping, Midi support, external keyboards, and more in Adobe Lightroom


Report this post
Top
 Profile  
Reply with quote  
 Post subject: troubleshooting tip
PostPosted: August 27th, 2011, 1:58 pm 
Offline

Joined: August 27th, 2011, 1:31 pm
Posts: 1
I tried setting up the voice control AHK occasionally for about a month. I didn't have any luck until recently. In case anyone has the same issues I did, here is how I fixed it. I believe this was originally intended by the script authors, but I didn't find the description clear. I am not a power user, so no guarantees.

If you are encountering the following when you try to run this script, then you should check that your script has a line including the proper COM.ahk file.
Quote:
ERROR: The COM Object may not be a valid Dispatch Object!


First, check if you have unicode or ANSI. This link (http://www.autohotkey.net/~Lexikos/AutoHotkey_L/docs/Compat.htm) describes how. Then make sure you have downloaded COM.ahk as is abundantly described at the start of this thread. Last, make sure your script include statement is pointed to the proper file. Here is mine for example.

Code:
#Include C:FilePathEdited\YourFilePathWillBeDifferent\AutoHotKey\lib\UNICODE\COM.ahk


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2011, 9:50 am 
dorfl68 wrote:
Question: Is there a way to switch off all SR contexts other than the one I am setting here? As I am playing with my script, windows tries to do all kinds of things in the background when I am slightly off with my pronunciation (I guess when it's not recognized for AHK it's handed to windows?)

Any solution to this? I have the same issue. I don't want it doing anything it hears except when it matches the words set in my script.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2011, 12:48 am 
Ok, I figured out how to get it to work on win7 and not recognize and act on the standard Windows commands by using SpInprocRecognizer. However now it recognizes things wrongly too often.
Does anyone know how to set the Confidence requirement engine wide or how to check the confidence value of the result? I'm not very good at COM yet and everything I try (based on my searches on MSDN) fails.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2011, 5:10 pm 
Offline

Joined: June 11th, 2010, 2:24 am
Posts: 78
Quote:
Ok, I figured out how to get it to work on win7 and not recognize and act on the standard Windows commands by using SpInprocRecognizer


Could you post how you did this? Thanks

_________________
Paddy For Lightroom!
Use AHK for keyboard mapping, Midi support, external keyboards, and more in Adobe Lightroom


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2011, 2:25 am 
Offline

Joined: January 26th, 2009, 5:26 pm
Posts: 151
Sorry it took so long to post it. Here is my working code. Not sure if its all correct or not and like I said though it recognizes too easily. For example saying ogle, noodle, poodle could all trigger Google
Code:
#Persistent
#SingleInstance force
OnExit, CleanUp


COM_Init()
plistener:= COM_CreateObject("SAPI.SpInprocRecognizer")
paudioin := COM_Invoke(paudioinputs:=COM_Invoke(plistener, "GetAudioInputs"), "Item", 0), COM_Release(paudioinputs)
;MsgBox % paudioin
COM_Invoke(plistener, "AudioInput", paudioin ? "+" . paudioin : "+0")
pcontext := COM_Invoke(plistener, "CreateRecoContext")
pgrammar := COM_Invoke(pcontext , "CreateGrammar")
COM_Invoke(pgrammar, "DictationSetState", 0)
prules := COM_Invoke(pgrammar, "Rules")
prulec := COM_Invoke(prules, "Add", "wordsRule", 0x1|0x20)
COM_Invoke(prulec, "Clear")
pstate := COM_Invoke(prulec, "InitialState")

; Add here the words to be recognized
COM_Invoke(pstate, "AddWordTransition", "+" . 0, "One")
COM_Invoke(pstate, "AddWordTransition", "+" . 0, "Two")
COM_Invoke(pstate, "AddWordTransition", "+" . 0, "Three")
COM_Invoke(pstate, "AddWordTransition", "+" . 0, "Google")
;;

COM_Invoke(prules, "Commit")
COM_Invoke(pgrammar, "CmdSetRuleState", "wordsRule", 1)
COM_Invoke(prules, "Commit")
pevent := COM_ConnectObject(pcontext, "On")
Return

CleanUp:
COM_Release(pevent)
COM_Release(pstate)
COM_Release(prulec)
COM_Release(prules)
COM_Release(pgrammar)
COM_Release(pcontext)
COM_Release(paudioin)
COM_Release(plistener)
COM_Term()
ExitApp

OnRecognition(prms, this)
{
   presult := COM_DispGetParam(prms, 3, 9)
   pphrase := COM_Invoke(presult, "PhraseInfo")
   sText   := COM_Invoke(pphrase, "GetText")
   COM_Release(pphrase)
;   Add custom operations from here!
If sText = One
   MsgBox, One
If sText = Two
   MsgBox, Two
If sText = Three
   MsgBox, Three
If sText = Google
   MsgBox, Google
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 129 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 9 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group