Interface: ISpeechRecoContext
Voice Property
The Voice property specifies the SpVoice object associated with the recognition context.
Syntax
Set: | SpeechRecoContext.Voice = SpVoice |
Get: | SpVoice = SpeechRecoContext.Voice |
Parts
- SpeechRecoContext
- The owning object.
- SpVoice
-
Set: An SpVoice object that sets the Voice property.
Get: An SpVoice object that gets the Voice property.
Remarks
ISpeechRecoContext.Voice allows the voice to be changed temporarily and for limited contexts. Change the voice using Speech properties in Control Panel.
Example
The first code snippet demonstrates speaking a successful recognition. The code represented is from the recognition event. Because SAPI makes extensive use of defaults, each recognition context will use the default system voice, which is specified using Speech properties in Control Panel.
Public WithEvents RC As SpSharedRecoContext
'Speech processing code goes here
Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
Label1.Caption = Result.PhraseInfo.GetText
RC.Voice.Speak Label1.Caption
End Sub
The next code sample changes the current voice to "Microsoft Sam" if it is available. The sample then speaks the new name. The sample assumes a valid RC at the time of the voice change.
Public WithEvents RC As SpSharedRecoContext
Set RC.Voice.Voice = RC.Voice.GetVoices("name=Microsoft Sam").Item(0)
RC.Voice.Speak "I have changed to " & RC.Voice.Voice.GetDescription