Share via


SpVoice Viseme event (SAPI 5.3)

Microsoft Speech API 5.3

Object: SpVoice (Events)

Viseme Event

The Viseme event occurs when the text-to-speech (TTS) engine detects a viseme boundary while speaking a stream for the SpVoice object.

  
    SpVoice.Viseme(
     StreamNumber As Long,
     StreamPosition As Variant,
     Duration As Long,
     NextVisemeId As SpeechVisemeType,
     Feature As SpeechVisemeFeature,
     CurrentVisemeId As SpeechVisemeType)

Parameters

  • StreamNumber
    The stream number which generated the event. When a voice enqueues more than one stream by speaking asynchronously, the stream number is necessary to associate an event with the appropriate stream.
  • StreamPosition
    The character position in the output stream at which the viseme begins.
  • Duration
    The duration of the viseme state.
  • NextVisemeId
    The next viseme ID.
  • Feature
    The SpeechVisemeFeature, which may indicate emphasis or stress on the viseme.
  • CurrentVisemeId
    The current viseme ID.

Example

The following Visual Basic form code demonstrates the Viseme event. To run this code, create a form with the following controls:

  • A command button called Command1
  • Two text boxes called Text1 and Text2

Paste this code into the Declarations section of the form.

The Form_Load procedure puts a text string in Text1 and creates a voice object. The command1_Click procedure calls the Speak method. This will cause the TTS engine to send the Viseme event to the voice. The Viseme event code will display the viseme values in Text2.

  Option Explicit

Public WithEvents vox As SpeechLib.SpVoice

Private Sub Command1_Click()

    vox.Speak Text1.Text, SVSFlagsAsync

End Sub

Private Sub Form_Load()

    Set vox = New SpVoice
    Text1.Text = "This is text in a text box."

End Sub

Private Sub vox_Viseme(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal Duration As Long, ByVal NextVisemeId As SpeechLib.SpeechVisemeType, ByVal Feature As SpeechLib.SpeechVisemeFeature, ByVal CurrentVisemeId As SpeechLib.SpeechVisemeType)

    Text2.Text = Text2.Text & CurrentVisemeId & " "

End Sub