ISpeechRecoGrammar IsPronounceable method (SAPI 5.4)

Microsoft Speech API 5.4

Interface: ISpeechRecoGrammar

IsPronounceable Method

The IsPronounceable method determines if a word has a pronunciation.

Additionally, the SpeechWordPronounceable constant returned by this method indicates whether the word exists in the grammar object's lexicon. Words are likely to be pronounceable even if they are not found in the lexicon.

     Word As String
) As SpeechWordPronounceable


  • Word
    Specifies the Word.

Return Value

A SpeechWordPronounceable constant.


The following Visual Basic form code demonstrates the use of the IsPronounceable method.

To run this code, create a form with the following controls:

  • A command button called Command1
  • A text box called Text1

Paste this code into the Declarations section of the form.

The Form_Load procedure creates a grammar and loads the general dictation topic. The Command1_Click procedure passes the word or words in Text1 to the IsPronounceable method and displays the resulting SpeechWordPronounceable constant.

Most correctly spelled words will be known and pronounceable; most incorrectly spelled words will be unknown and pronounceable. The example begins with a word which is pronounceable, even though it is misspelled.

Option Explicit

Dim MyRecoContext As SpeechLib.SpSharedRecoContext
Dim MyGrammar As SpeechLib.ISpeechRecoGrammar

Private Sub Command1_Click()
    On Error GoTo EH

    Dim strTemp As String

    Select Case MyGrammar.IsPronounceable(Text1.Text)
        Case SWPKnownWordPronounceable
            strTemp = "KnownWordPronounceable"
        Case SWPUnknownWordPronounceable
            strTemp = "UnknownWordPronounceable"
        Case SWPUnknownWordUnpronounceable
            strTemp = "UnknownWordUnpronounceable"
    End Select

    MsgBox "The word """ & Text1.Text & """ is " & strTemp

    If Err.Number Then ShowErrMsg
End Sub

Private Sub Form_Load()
    On Error GoTo EH

    Set MyRecoContext = New SpSharedRecoContext
    Set MyGrammar = MyRecoContext.CreateGrammar

    MyGrammar.DictationLoad ""

    Text1.Text = "missspeled"

    If Err.Number Then ShowErrMsg
End Sub

Private Sub ShowErrMsg()

    ' Declare identifier:
    Dim T As String

    T = "Desc: " & Err.Description & vbNewLine
    T = T & "Err #: " & Err.Number
    MsgBox T, vbExclamation, "Run-Time Error"

End Sub