Do you ever think to make an application which can speak based on specific texts?
With several lines of code, you really can realize your dream ![]()
Using Microsoft Speech Library Object, we can use speak method of an object.
Talking less, let's see below code ![]()
Notice this parameter 'SpeechVoiceSpeakFlags.SVSFlagsAsync'.
That is one of SpeechVoiceSpeakFlags Enum which can control SpVoice.Speak method.
For more information of SpeechVoiceSpeakFlags Enum, please visit this link MSDN
Download source code
Code:
Option Strict On
Option Explicit On
Imports SpeechLib
Public Class Form1
Private Sub btnSpeakIt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSpeakIt.Click
Dim oSpeaker As New SpVoice
Try
If Trim(txtTextMessage.Text) = "" Then
MessageBox.Show("Please input your text message for testing.", "Speaker", MessageBoxButtons.OK, MessageBoxIcon.Information)
txtTextMessage.Focus()
Else
oSpeaker.Speak(Trim(txtTextMessage.Text), SpeechVoiceSpeakFlags.SVSFlagsAsync)
End If
Catch ex As Exception
MessageBox.Show(ex.Message.ToString, "Speaker", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class
0 comments:
Subscribe to:
Post Comments (Atom)

Post a Comment