Registering and logging in removes this ad.
Registering and logging in removes this ad.
advice on how to use natlink.recognitionMimic()
Submitted by MarkUK on Fri, 05/23/2008 - 12:19.
I would be grateful for some advice on the use of natlink.recognitionMimic() .
I have been trying the following code without success... looking at the various examples I cannot see anything wrong with it but I persistently get the following error messages.
capitalize
natlink.MimicFailed: recognitionMimic call failed (The speech engine returned the following error: MimicNoResults)
Capitalize or Capitalize That
natlink.MimicFailed: recognitionMimic call failed (The speech engine returned the following error: BadWord)
# capitalise line
def gotResults_48(self, words, fullResults):
natlink.playString('{Home}{Shift+End}')
s = ['capitalize', 'that']
s = ['Capitalize', 'that']
s = ['Capitalize', 'That']
## s = str(s) # this does not change the error message.
natlink.playString(s)
natlink.playString('{Enter}')I can achieve the same result with the following code, but a very puzzled why I cannot get it to work with Natlink.
# capitalise line
def gotResults_48(self, words, fullResults):
natlink.playString('{Home}{Shift+End}{Ctrl+x}')
s = natlink.getClipboard()
s = string.capwords(s)
natlink.playString(s)Mark



Well it shows up when
Well it shows up when quoting it, but it disappears when I try to post it. So probably part of your post is being interpreted as HTML tags.
Otherwise, I can't advise on the issue
Bruce
Wow. The first post to blow
Wow. The first post to blow us up.
I managed to get it working by using the rich text editor for input then submitting it.
Skip
Update: I figured out what it was. An update was required that I was unaware of. Fixed now.
Many thanks for sorting this
Many thanks for sorting this out... any ideas on the Natlink problem?
Mark
PS. I did paste this in from DragonPad.. does not usually cause problems...
MarkUK wrote: any ideas on
any ideas on the Natlink problem?
I've never used Natlink so I'm a bit clueless there. I'm sure there are others that are FAR more able to answer you though.
Skip
MarkUK wrote: Many thanks
Many thanks for sorting this out...
You're quite welcome. It bothers me when it doesn't do what it should. A security upgrade blew up the <code> module. All fixed now as it's all upgraded.
Hello Mark, Try the code
Hello Mark,
Try the code below. Instead of your keystrokes, which are probably secure and faster, you can also do another recognitionMimic.
Note the two backslashes: they are by python converted into one backslash, meaning "Capitalize that" is considered as a spoken form. I do not understand this, as it is clearly a command. I couldn't find this command in the command browser though.
Note 2: "Capitalize that" only works in a select and say window, or possibly on the last phrase you spoke.
Note 3: "Capitalize that" works slightly different as the python function "string.capwords": NatSpeak doesn't capitalize small words like "for", "in", "the" etc.
Note 4: In your cut and playString example you can also consider to put the new string on the clipboard and paste again. Faster in some situations. You can most easily do this by using some unimacro functions.
Success, greetings, Quintijn
def gotResults_test(self,words,fullResults): """ try recognition mimic """ ## natlink.playString("{home}{shift+end}") natlink.recognitionMimic(['select', 'line']) time.sleep(0.1) natlink.recognitionMimic(['\\Capitalize', 'that'])Quote: Note the two
Note the two backslashes: they are by python converted into one backslash, meaning "Capitalize that" is considered as a spoken form. I do not understand this, as it is clearly a command. I couldn't find this command in the command browser though.
Hi Quintijn,
Many thanks for that, this works perfectly.
I had spotted the \\ in your Unimacro macro files, but unfortunately I tried them both on the capitalise and on the that... but both at the same time which did not quite work.
At the moment I am very happy with my progress in NatPythonising my global macros and getting rid of the corresponding Vocola scripts. Even on this computer, which is a 1.6 GHz Core2 duo with 1 GB of RAM, this seems to speed up the response time considerably. I do plan to publish suitable extracts on the speech wiki as there seems to be a paucity of simple coding to show beginners how to start coding in NatPython... now I have actually found out how to do it, it really does not seem any more complicated than doing it in Vocola.
Regards
Mark
MarkUK wrote: At the moment
At the moment I am very happy with my progress in NatPythonising my global macros and getting rid of the corresponding Vocola scripts. Even on this computer, which is a 1.6 GHz Core2 duo with 1 GB of RAM, this seems to speed up the response time considerably. I do plan to publish suitable extracts on the speech wiki as there seems to be a paucity of simple coding to show beginners how to start coding in NatPython... now I have actually found out how to do it, it really does not seem any more complicated than doing it in Vocola.
Sweet