views:

31

answers:

1

I have this Windows Speech Recognition (WSRMacro) script which compounds multiple words that are spoken into a single word:

"Happy children"
-> "Happychildren"

However, a bug in the script appears under certain circumstances and I do not know how to deduce what the problem is. Although the above example works, the following does not:

"Happy children bake a cake"

Instead of compounding the words as above, the Alternates Panel appears with the following prompt:

-> Alternates Panel (Say the number next to the item you want followed by OK): 
(1) Replace that withhappychildrenbakeacake
(2) replace that withhappychildrenbakeacake
(3) replace that with no space happy no space 
    children no space bake no space a no space cake

Can I infer any particular bug in the script below from the Alternates Panel output above?

Or is there anything I can add to the script to get more useful feedback about the nature of the bug?

  <command priority="5">
    <listenFor>compound that</listenFor>
    <emulateRecognition>select that</emulateRecognition>
    <sendKeys>{250 WAIT}{{CTRL}}c{250 WAIT}</sendKeys>
    <script language="VBScript">
      <![CDATA[
      that = Application.clipboardData.GetData("text")
      Set regEx = New RegExp
      regEx.Pattern = "[^\s\w,;:]"
      If regEx.Test(that) Then
        Application.SetTextFeedback("Try again without any punctuation selected")
      Else
        regEx.Pattern = "(\s) *(\S)"
        regEx.Global = True
        that = regEx.Replace(" " & that, "$1no space $2")
        On Error Resume Next
        Application.EmulateRecognition("replace that with" & that)
        If 0 <> Err.Number Then
          Application.SetTextFeedback("Try again with only the digits selected")
        End If
      End If
    ]]>
    </script>
  </command>
A: 

Sounds like you're trying to use this in an application that doesn't natively support Text Services Framework.

More seriously, why aren't you using the builtin commands 'Remove spaces from that' or 'concatenate that'?

Eric Brown