SpVoice Volume property (SAPI 5.4)
Microsoft Speech API 5.4
Object: SpVoice
Volume Property
The Volume property gets and sets the base volume (loudness) level of the voice.
Values for the Volume property range from 0 to 100, representing the minimum and maximum volume levels, respectively.
At the beginning of each Speak or SpeakStream method, the voice sets the volume level according to the value of the Volume property, and speaks the entire stream at that level. The voice's Volume property can be changed at any time, but the actual volume level will not reflect the changed property value until it begins a new stream.
Syntax
Set: | SpVoice.Volume = Long |
Get: | Long = SpVoice.Volume |
Parts
- SpVoice
The owning object. - Long
Set: A Long variable that sets the property value.
Get: A Long variable that gets the property value.
Example
The following Visual Basic form code demonstrates the use of the Rate and the Volume properties. To run this code, create a form with the following controls:
- A command button called Command1
- A text box called Text1
- A VScrollbar called VScroll1
- An HScrollbar called HScroll1
Paste this code into the Declarations section of the form.
The Form_Load procedure creates a voice object and associates the VScrollbar with the voice's Volume property and the HScrollbar with the voice's Rate property. Adjusting the scroll bars changes the settings of the Volume and Rate properties. The Command1_Click procedure speaks a phrase in order to demonstrate the effects of the changes.
Option Explicit
Private V As SpeechLib.SpVoice
Private Sub Command1_Click()
V.Speak "The quick brown fox jumped over the lazy dog.", SVSFlagsAsync
End Sub
Private Sub Form_Load()
Set V = New SpeechLib.SpVoice
VScroll1.Min = 0
VScroll1.Max = 100
VScroll1.Value = V.Volume
HScroll1.Min = -10
HScroll1.Max = 10
HScroll1.Value = V.Rate
Text1.Text = "Vol: " & VScroll1.Value & "; Rate: " & HScroll1.Value
End Sub
Private Sub HScroll1_Change()
V.Rate = HScroll1.Value
Text1.Text = "Vol: " & VScroll1.Value & "; Rate: " & HScroll1.Value
End Sub
Private Sub VScroll1_Change()
V.Volume = VScroll1.Value
Text1.Text = "Vol: " & VScroll1.Value & "; Rate: " & HScroll1.Value
End Sub