KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up
Topic Summary: need to find replacement for 'format that spelled out'
Created On: 10/08/2015 01:46 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - format that spelled out can't let you go - 10/08/2015 01:46 PM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - PG LTU - 10/08/2015 03:20 PM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - Ishmael - 10/08/2015 04:42 PM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - Alan Cantor - 10/09/2015 11:00 AM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - PG LTU - 10/09/2015 11:29 AM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - Ishmael - 10/09/2015 11:51 AM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - Alan Cantor - 10/09/2015 01:54 PM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - PG LTU - 10/09/2015 02:27 PM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - PG LTU - 10/09/2015 02:43 PM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - Ishmael - 10/09/2015 04:30 PM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - Gene - 10/09/2015 02:43 PM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - Ishmael - 10/09/2015 03:13 PM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - format that spelled out can't let you go - 10/12/2015 05:55 AM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - Jomark - 10/13/2015 11:53 AM  
 formatting numbers as words, you know, like Dragon used to do so well before they stuffed it up   - PG LTU - 10/13/2015 06:48 PM  
Keyword
 10/08/2015 01:46 PM
User is offline View Users Profile Print this message

Author Icon
format that spe..
New Member

Posts: 2
Joined: 10/08/2015

Does anyone know of any third party software that would do what 'format that
spelled out' used to do before nuance got rid of it? I work with
rubles so really need it. Have tried installing my 9.5 on W7 64-bit laptop
but it seems to fall into a hole between the 9 on W7 and 9 on Vista
workarounds and I end up with .cab file problems that I just don't have the knowledge to sort out. This function is so important to me that I have been retarding my computing life for years now by sticking with XP. Nuance will not put the function back, although I have told them that I was alerted to its loss by another translator, warned me it was gone and not to upgrade - have to say that, actually, I have yet to speak to anyone at Nuance who know's what I'm on about. 

I'm trying to pre-sort dragon on my W7 laptop before switching my workstation
over completely, can't set up new system until I've run it in on laptop. Any suggestions? I cannot be the only person who can't do without it! Happy to upgrade DNS if somebody's got a wotnot I can tag on to it.

Huge thanks for any advice

 10/08/2015 03:20 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2197
Joined: 03/21/2007

Well, interestingly enough, in DPro 13 the recognition history for all numbers has them spelled out and it is the smart formatting rules that converts them to numbers depending on the setting. So if you say a number like "12,345" the recognition history shows "twelve thousand three hundred forty five" and if you immediately say "correct that" you get a choice with the spelled-out version. Then when you select that choice, you get another dialog box asking if you want to turn of formatting as numbers entirely. Once you do that, all numbers are spelled out.


And, actually, in the auto formatting options you can immediately turn off Numbers without going through that step. Then, to get the numbers, just say "numeral" before the number.


Or, using the [dictation] open variable, you could write a command that parses out the spelled out representation from the numeric-formatted recognized utterance.

-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.

 10/08/2015 04:42 PM
User is offline View Users Profile Print this message

Author Icon
Ishmael
Junior Member

Posts: 31
Joined: 08/10/2015

If you've got a version of DNS that can do custom commands, you can use this command. I think you need references to DgnMyCommands and Dragon NaturallySpeaking ActiveX Controls, or least my command has them.

Sub Main
Dim engine As New DgnEngineControl
engine.DlgShow(dgndlgRecognitionHistory, 0, , 0)

Wait .4
SendKeys "{Up}"

Wait .1
SendKeys "{Tab}"
Wait .1
SendKeys "^c"
Wait .1
SendKeys "{Tab 3}~"
Wait .1
SendKeys "^z
Wait .5
SendKeys"^v"
End Sub
 10/09/2015 11:00 AM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4280
Joined: 12/08/2007

Nice script! I did not need to make any references.

I was able to speed up the script by inserting the undo step at the start of the script; reducing or eliminating the time delays; and by sending Esc to close the Recognition History window rather than tabbing to the Close button.

In actual use, it may prove necessary to increase the time delays. But this is working reliably for me:

Sub Main
SendKeys "^z" ' Undo
Wait .3 ' Need a short delay
Dim engine As New DgnEngineControl
engine.DlgShow(dgndlgRecognitionHistory, 0, , 0) ' Invoke recognition history
Wait .1
SendKeys "{Up}"
' Wait .1
SendKeys "{Tab}"
' Wait .1
SendKeys "^c" ' Copy to the clipboard
' Wait .1
SendKeys "{Esc}" ' Close recognition history
Wait .1
SendKeys "^v" ' Paste
End Sub
 10/09/2015 11:29 AM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2197
Joined: 03/21/2007

Alan already deleted (or rather commented out) some of the waits. For additional dependability, the SendKeys should include the "Wait" flag (use "True" or "1"):

Syntax
SendKeys Keys$[, Wait]

Parameter Description
Keys$ : Send the keys in this string value to Windows. (Refer to table below.)
Wait : If this is not zero then the keys are sent before executing the next instruction. If this is omitted or zero then the keys are sent during the following instructions.

-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.

 10/09/2015 11:51 AM
User is offline View Users Profile Print this message

Author Icon
Ishmael
Junior Member

Posts: 31
Joined: 08/10/2015

Thanks for the improvements. I noticed yesterday that it seems to have one flaw: it doesn't include a "-" for words like 32/thirty-two. I'm having trouble thinking about how to fix this, other than by running some sort of Replace instruction that would replace the " " with "-".
 10/09/2015 01:54 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4280
Joined: 12/08/2007

This may do the trick. It substitutes "ty " (i.e., T Y space) which is the ending of twenty, thirty... ninety for "ty-"

Sub Main
SendKeys "^z" ' Undo
Wait .3 ' Need a short delay
Dim engine As New DgnEngineControl
engine.DlgShow(dgndlgRecognitionHistory, 0, , 0) ' Invoke recognition history
Wait .1
SendKeys "{Up}"
' Wait .1
SendKeys "{Tab}"
' Wait .1
SendKeys "^c" ' Copy to the clipboard
' Wait .1
SendKeys "{Esc}" ' Close recognition history
Wait .1
Dim x As String
x = Replace (Clipboard, "ty ", "ty-")
SendKeys x
End Sub
 10/09/2015 02:27 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2197
Joined: 03/21/2007

Since "ty " may appear within the phrase, eg. 130,415 is "one hundred thirty thousand four hundred and fifteen" this might give spurious results. Perhaps:

x=Clipboard

If InStr(Right(x,8),"ty") Then x = Left(x,Len(x)-8) & Replace(Right(x,8), "ty ", "ty-")

SendKeys x,True


(but I can't test right now . . .)



-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



 10/09/2015 02:43 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2197
Joined: 03/21/2007

Well, that might not work so good for 133,415 which should be "one hundred thirty-three thousand four hundred and fifteen"

-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.

 10/09/2015 04:30 PM
User is offline View Users Profile Print this message

Author Icon
Ishmael
Junior Member

Posts: 31
Joined: 08/10/2015

Originally posted by: PG LTU Well, that might not work so good for 133,415 which should be "one hundred thirty-three thousand four hundred and fifteen"

You're right.  But I was mostly focused on smaller numbers, so I can live with this minor glitch.  At worst, I'll tell Dragon to select the words that need to be hyphenated and say "hyphenate that".

 10/09/2015 02:43 PM
User is offline View Users Profile Print this message

Author Icon
Gene
Power Member

Posts: 48
Joined: 03/05/2007

Are you using DNS 9.5? Most people have a good reason for using old apps. However, DNI 14 has ISO currency options built-in such as USD35, CAD25, AUD25.75, etc., but not 25 Russian rubles. I can only get it to work on those three currencies. I don't know if you Linus knows much about this fairly new (?) option. It might be a tad tedious, but since these are alphanumeric, I think even version 9.5 would allow you to dictate Belarusian rubles as BRR. I can't remember if version 9.5 would let you insert formatting commands into custom "words" so that AUD25 did not come out as AUD 25. After you entered the new vocabulary I would assume you could dictate "35.75 no space Mexican pesos" and get 35.75MXP".



 10/09/2015 03:13 PM
User is offline View Users Profile Print this message

Author Icon
Ishmael
Junior Member

Posts: 31
Joined: 08/10/2015

seems to work beautifully!
 10/12/2015 05:55 AM
User is offline View Users Profile Print this message

Author Icon
format that spe..
New Member

Posts: 2
Joined: 10/08/2015

Thanks so much for all of this advice, really good of you to give up your time and I will definitely use that script if have to upgrade - new for me to deal with scripts so might well be back for more advice some time soon! I will in meantime see if I can get 9.5 working on W7 - it's the utility of being able to say "1,299,349,284, copy that, open brac, paste that, format that spelled out, close brac" that is so great - it's for contracts and other docs that have the figure followed by the number in brackets, so globally changing to figures or numbers doesn't do it, although am wondering about setting to spelled out, copying, pasting then using 'correct that' for first use. Am going to explore using 9.5 in virtual xp environment but don't know whether the 64-bit issue would still be a problem and, if so, whether dropping the launch conditions would lead me through the same maze of .cab file problems I've had so far. AND they've already stopped supporting it so I'm really just putting off the evil day of upgrading DNS. Why they have got rid of such a fantastic function while adding endless, pointless bells and whistles is beyond me but I mustn't start with all that!
 10/13/2015 11:53 AM
User is offline View Users Profile Print this message


Jomark
Top-Tier Member

Posts: 1505
Joined: 10/19/2006

In the past I created a command to format numbers spelt out and more specifically for a particular currency and incorporating formatting of the words with capitals and bold. I found that by simply having the numbers spelt out in words and then applying formatting to the words did not work and in fact the words format of the number reverted back to the numerical version.


Whole numbers worked reasonably well but when dictating currency values with whole numbers and parts e.g. £15-21, it doesn't work that well if at all. The problem is that the required format of the number doesn't always appear as the number 1 entry in the "Choose That" box.
I have tried out the scripts detailed here in this thread and whilst the scripts seem to deploy a little faster than my clunky effort, it still has the problem of reverting back to the numerical format when one tries to format the words by capitalisation and bold.
Sub Main
HeardWord "view","recognition","history"
Wait .5
SendDragonKeys "{Up 2}{Tab}"
SendDragonKeys "{Ctrl+c}"
Wait .5
SendSystemKeys "{Alt+F4}"
Wait 1
HeardWord "select","that"
Wait 1
HeardWord "choose","one"
HeardWord "select","that"
'SendKeys "{Esc}" ' Close recognition history
'Wait .1
'SendKeys "^v" ' Paste
SendDragonKeys "{Alt+h}7c"
HeardWord "unselect","that"
End Sub


-------------------------

Jomark


 


DPI 15.61, KB2017, SpeechStart+, MS Office 2019 Professional, Windows 10 Pro

 10/13/2015 06:48 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2197
Joined: 03/21/2007

This comes awfully close to a complete solution.  It is limited in that it doesn't handle bigger than millions, nor do I cover currency symbols and multi-part (decimal cents, etc.); but it should be easily extended to cover those things (and it is fun to work on, so maybe I will).  You can run it from the command browser "run" button to try out what gets dictated (just dictate into the input box).  Your milage may vary.

 

Sub Main

If UtilityProvider.IsDebugMode Then  '  for debugging/testing

    i=InputBox("Dictate a numerical number or type it in using commas","Spell it Out")

    UtilityProvider.SetContextValue ( 0 , i )

End If

x=ListVar1

If Len(x)=4 Then x=Left(x,1) & "," & Mid(x,2)  '  4 digits needs a comma seperator

If InStr(x,",") Then  '  x at least in the thousands

    y=Mid(x,InStr(x,",")+1)  '  save the part after the first comma

    If InStr(y,",") Then  '  x at least in the millions

        If Len(Left(x,InStr(x,",")-1))=3 Then  '  3 digits means there is a hundreds place

            rm=ones(Left(x,1)) & " hundred "  '  ones is the hundreds digit

            x=Mid(x,2,2) & "," & y  '  the remaining two digits

        End If

        rm=rm & Mid(twonum(Left(x,InStr(x,",")-1)),5) & " million "  '  how many million (mid removes the "and" from twonum)

        x=y  '  return just the Thousands places

    End If  '  end millions processing

    If Left(x,3) = "000" Then GoTo cont  '  skip if no Thousands digits

    If Left(x,1) = 0 Then x=Right(x,Len(x)-1)  '  no hundred-thousand digit, trim the 0 off

    If Len(Left(x,InStr(x,",")-1))=3 Then  '  there is a hundred-thousand digit

        rt=ones(Left(x,1)) & " hundred "  '  the hundred-thousand digit

        x=Mid(x,2)

    End If

    rt=rt & Mid(twonum(Left(x,InStr(x,",")-1)),5) & " thousand "  '  how many thousand (mid removes the "and" from twonum)

cont:

    x=Mid(x,InStr(x,",")+1)  '  return just the Hundreds places

End If  '  End thousands processing

' hundreds or less

    If Len(x)=3 Then  '  there is a hundreds digit

        If Left(x,1)>0 Then rh=ones(Left(x,1)) & " hundred "

        x=Right(x,Len(x)-1)  '  return just the Tens places

    End If  '  End hundreds processing

    If Len(ListVar1)>1 Then  '  there is a tens digit

        If Len(ListVar1)=2 Then ro=Mid(twonum(x),5)  '  no "and" for 2 digit numbers

        If Len(ListVar1)>2 Then ro=twonum(x)

    End If

    If Len(x)=1 Then ro=ones(x)

spelled=rm & rt & rh & ro

If Right(spelled,1)="-" Then spelled=Left(spelled,Len(spelled)-1)  '  trim trailing "-"

If Right(spelled, 5)=" and " Then spelled=Left(spelled,Len(spelled)-5)  '  trim trailing "and"

spelled=Replace(spelled,"  "," ")  '  fix two adjacent spaces

MsgBox ListVar1 & " is" & vbCrLf & """" & spelled & """" & _

    vbCrLf & vbCrLf & "Clipboard contains:" & vbCrLf & _

        spelled & " (" & ListVar1 & ") "'  let's see what we got

Clipboard(spelled & " (" & ListVar1 & ") ")

' SendKeys spelled & " (" & ListVar1 & ") ",True  '  uncomment to send keys directly

End Sub

Function twonum(a)

    If Left(a,1)=0 Then

        twonum="and " & ones(Right(a,1))

    ElseIf Left(a,1)=1 Then

        twonum="and " & ones(a)

    ElseIf Len(a)=1 Then

        twonum="and " & ones(a)

    Else

        twonum="and " & tones(Left(a,1)) & "-" & ones(Right(a,1))

    End If

End Function


Function ones(a)

    Select Case a

        Case "1"

            ones="one"

        Case "2"

            ones="two"

        Case "3"

            ones="three"

        Case "4"

            ones="four"

        Case "5"

            ones="five"

        Case "6"

            ones="six"

        Case "7"

            ones="seven"

        Case "8"

            ones="eight"

        Case "9"

            ones="nine"

        Case "10"

            ones="ten"

        Case "11"

            ones="eleven"

        Case "12"

            ones="twelve"

        Case "13"

            ones="thirteen"

        Case "14"

            ones="fourteen"

        Case "15"

            ones="fifteen"

        Case "16"

            ones="sixteen"

        Case "17"

            ones="seventeen"

        Case "18"

            ones="eighteen"

        Case "19"

            ones="nineteen"

    End Select

End Function


Function tones(a)

    Select Case a

        Case "2"

            tones="twenty"

        Case "3"

            tones="thirty"

        Case "4"

            tones="forty"

        Case "5"

            tones="fifty"

        Case "6"

            tones="sixty"

        Case "7"

            tones="seventy"

        Case "8"

            tones="eighty"

        Case "9"

            tones="ninety"

    End Select

End Function

 

Hth



-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



Statistics
32286 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 1 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 375 guests browsing this forum, which makes a total of 376 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2022 FuseTalk™ Inc. All rights reserved.