You are reading help file online using chmlib.com
|
Object: SpVoice
The GetVoices method returns a selection of voices available to the voice.
Selection criteria may be applied optionally. In the absence of selection criteria, all voices are returned in the selection, ordered alphabetically by the voice name. If no voices match the criteria, GetVoices returns an empty selection, that is, an ISpeechObjectTokens collection with a Count of zero.
See Object Tokens and Registry Settings White Paper for a list of SAPI 5-defined attributes.
SpVoice.GetVoices(
[RequiredAttributes As String = ""],
[OptionalAttributes As String = ""]
) As ISpeechObjectTokens
An ISpeechObjectTokens variable containing the collection of voice tokens selected.
The format of selection criteria is "Attribute = Value" and "Attribute != Value." Voice attributes include "Gender," "Age," "Name," "Language," and "Vendor."
The following Visual Basic form code demonstrates the use of the GetVoices method and the Voice property. To run this code, create a form with the following controls:
Paste this code into the Declarations section of the form.
The Form_Load procedure creates a voice object, and displays the names of all available voices in the list box. Select a voice name in the list box, and then click Command1. The Command1 procedure sets the voice object's Voice property to the selected name, and causes the voice to speak its new name.
Option Explicit
Private V As SpeechLib.SpVoice
Private T As SpeechLib.ISpeechObjectToken
Private Sub Command1_Click()
If List1.ListIndex > -1 Then
'Set voice object to voice name selected in list box
'The new voice speaks its own name
Set V.Voice = V.GetVoices().Item(List1.ListIndex)
V.Speak V.Voice.GetDescription
Else
MsgBox "Please select a voice from the listbox"
End If
End Sub
Private Sub Form_Load()
Dim strVoice As String
Set V = New SpVoice
'Get each token in the collection returned by GetVoices
For Each T In V.GetVoices
strVoice = T.GetDescription 'The token's name
List1.AddItem strVoice 'Add to listbox
Next
End Sub
You are reading help file online using chmlib.com
|