KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: How to convert dictated text to sentence case?
Topic Summary:
Created On: 10/04/2020 07:08 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 How to convert dictated text to sentence case?   - wristofdoom - 10/04/2020 07:08 PM  
 How to convert dictated text to sentence case?   - PG LTU - 10/04/2020 08:54 PM  
 How to convert dictated text to sentence case?   - Alan Cantor - 10/04/2020 09:49 PM  
 How to convert dictated text to sentence case?   - Edgar - 10/05/2020 11:22 AM  
 How to convert dictated text to sentence case?   - kkkwj - 10/06/2020 12:01 PM  
Keyword
 10/04/2020 07:08 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Power Member

Posts: 63
Joined: 09/03/2020

Hi, I have a script where I want to convert some text that I dictate into sentence case capitalization, Where The First Character Of Every Word In The Dictated Phrase Is Capitalized, Like This.

 

I know how to convert my dictated text to all capitalization:

        SendKeys UCase ListVar1

what I want is to do the same thing but with sentence case:


        SendKeys SCase ListVar1


unfortunately, that does not seem to be a command.

 

Any ideas?



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

Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017.

 10/04/2020 08:54 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2100
Joined: 03/21/2007

Otherwise known as Title Case or in the Basic world, Proper Case and it is not supported.
https://www.winwrap.com/web2/basic/#!/ref/WWB-doc_strconv_func.htm

If you know a little regex, or if you want to send your text to an outside script maybe, but otherwise, let us know what you come up with . . .



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




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/04/2020 09:49 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 3869
Joined: 12/08/2007

If you are dictating into Microsoft Word, there are built-in commands to capitalize sentences.

"capitalize sentence"

This command acts on the current sentence, as long as the cursor is somewhere within the boundaries of the sentence. There's no need to select the sentence.

You can also capitalize nearby sentences (or lines, paragraphs, sections, etc.)

"capitalize previous line | sentence | paragraph | section"

"capitalize next line | sentence | paragraph | section"

"capitalize previous [1-999] lines | sentences | paragraphs | sections"

"capitalize next [1-999] lines | sentences | paragraphs | sections"

However, these commands only work in Microsoft Word.
 10/05/2020 11:22 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 939
Joined: 04/03/2009

Sub Main
   ' Dim capitalizedResult As String
   ' something must be selected but function at this time does not
   ' check for that
   TitleCase ' the selected text is now on the clipboard
      ' in title-case-on-steroids
      ' that means that even words like "and" are capitalized
   ' capitalizedResult = Clipboard
   ' do with capitalizedResult as you wish, or
   ' the selected text is still selected so can be pasted over:
   SendKeys "^v", 1
End Sub

Function TitleCase ()

'WinWrap Basic by Lindsay Adam www.pcbyvoice.com

' modified by Alan Cantor to capitalize the first letter of a paragraph

'    and the first letter after a tab

'modified by edgar to start with the first word's letter

'    and to make sure that the first letter after an:

'    open parentheses ( , open square bracket [ , an open quote " ,

'    an open curly quote “, a dash – , a bullet point ? , or a hyphen -

'    get capitalized


   Dim capNext As Boolean

   Dim clip, internalText, characterToChange, precedingCharacter As String

   Dim length As Integer

   capNext = True

   internalText = ""

   characterToChange = ""

   precedingCharacter = "a"


   SendKeys "^c", 1

   Wait 0.3

   clip = Clipboard

   Wait 0.3


   length = Len (clip)

   For iteration = 1 To length

      characterToChange = Mid(clip, iteration, 1)

      If iteration > 1 Then

         precedingCharacter = Mid(clip, iteration - 1, 1)

         If precedingCharacter = "(" Then

            capNext = True

         ElseIf precedingCharacter = "[" Then

            capNext = True

         ElseIf precedingCharacter = "¿" Then

            capNext = True

         ElseIf precedingCharacter = "…" Then

            capNext = True

         ElseIf precedingCharacter = Chr$(149) Then 'bullet point

            capNext = True

         ElseIf precedingCharacter = Chr$(147) Then 'open curly quote “

            capNext = True

         ElseIf precedingCharacter = Chr$(34) Then 'open regular quote "

            capNext = True

         ElseIf precedingCharacter = "-" Then

            capNext = True

         ElseIf precedingCharacter = Chr$(150) Then 'dash –

            capNext = True

         ElseIf precedingCharacter = Chr$(161) Then 'inverted exclamation mark ¡

            capNext = True

         End If

      End If

      If capNext And (characterToChange >= "a" Or characterToChange <= "z") Then

         internalText = internalText & UCase (characterToChange)

         capNext = False

      Else

         internalText = internalText & characterToChange

      End If

      If characterToChange = " " Or characterToChange = Chr$(9) Or _

      characterToChange = Chr$(10) Or characterToChange = Chr$(13) Or _

      characterToChange = Chr$(34) Then

         capNext = True

      End If

   Next iteration


   Wait 0.3

   Clipboard internalText

   Wait 0.3

End Function



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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 10/06/2020 12:01 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 512
Joined: 11/05/2015

When you're working with TitleCase, there are various style rules that you can follow (Chicago Manual of Style, APA, and so on). All but the Chicago one (I think) will capitalize words of 4 characters or more, such as From vs. from. Also, the first word of a title is always capitalized, regardless of the length (I, To, The, ...). Also, abbreviations such as IBM should have all characters capitalized. And so on. There are quite a few rules and special cases to consider, depending on how smart you want your script to be.

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

Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.3, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones

Statistics
31833 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 481 guests browsing this forum, which makes a total of 482 users using this forum.

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