advice on how to use natlink.recognitionMimic()

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

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 Sad

Bruce

admin's picture

Wow. The first post to blow

Wow. The first post to blow us up. Smiling

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. Laughing out loud

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...

admin's picture

MarkUK wrote: any ideas on

MarkUK wrote:

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

admin's picture

MarkUK wrote: Many thanks

MarkUK wrote:

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

Quote:

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

MarkUK wrote:

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 Smiling

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.




view recent posts