Example with MS Agent, text-to-speech

By | 2002-06-01

Microsoft Agent will speak (computerized voice) the contents of a textbox or richtextbox to you!

Original Author: Amir Malik

Inputs

the text to speak, or just paste it

Assumptions

components/objects:
Microsoft Direct Text-to-Speech control
rich text box
2 command buttons
the sp is the DirectSS control
text box for the computer voice speed

Returns

sound!

Code

' MSAGENT example by Amir Malik
' website: http://amir142.cjb.net
' e-mail : amir@infoteen.com

Private Sub cmdPaste_Click()
  TextData.Text = Clipboard.GetText
End Sub
Private Sub cmdPauseR_Click()
  If cmdPauseR.Caption = "&Pause / Stop" Then
    sp.AudioPause
    cmdPauseR.Caption = "&Resume"
  ElseIf cmdPauseR.Caption = "&Resume" Then
    sp.AudioResume
    cmdPauseR.Caption = "&Pause / Stop"
  End If
End Sub
Private Sub cmdSpeak_Click()
  sp.Speak TextData.Text
  sp.Speed = txtSpeed.Text
  Sspeak = True
End Sub
Private Sub txtSpeed_LostFocus()
  If txtSpeed.Text < 50 Then
    MsgBox "Speed is too low."
    txtSpeed.Text = "150"
  End If
  If txtSpeed.Text > 250 Then
    MsgBox "Speed is too high."
    txtSpeed.Text = "150"
  End If
End Sub

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.