Saturday, April 5, 2008

Convert English text to voice



Main Title: Voice Interface
Project: Convert English text to voice
Developer: Md. Redwanur Rahman
Location: Dhaka, Bangladesh.
Date: 25 September, 2007

I am here to share knowledge with other. I am writing about voice interface project.

Aim of this project
Sometimes to read may bore. Wish someone may read it and I may enjoy to listen. Important news or weather report from web will convert to voice using these codes. These codes also convert your text in .wav format that will play by Media player

Needed component
Sapi.dll file (if not in computer download form Microsoft)

Program Details
Option Explicit
Dim Voice As SpVoice
Private Sub Form_Load()
Set Voice = New SpVoice
End Sub
Private Sub ExitBtn_Click()
Unload Form1
End Sub
Private Sub SpeakItBtn_Click()
On Error GoTo Speak_Error
If SaveToWavCheckBox Then
SaveToWav
Else
If Not TextField.Text = "" Then
Voice.Speak TextField.Text, SVSFlagsAsync
End If
End If
TextField.SetFocus
Exit Sub
Speak_Error:
MsgBox "Speak Error!", vbOKOnly
End Sub

Private Sub SaveToWav()
Dim cpFileStream As New SpFileStream
cpFileStream.Format.Type = SAFT22kHz16BitMono
ComDlg.CancelError = True
On Error GoTo Cancel
ComDlg.Flags = cdlOFNOverwritePrompt + cdlOFNPathMustExist + cdlOFNNoReadOnlyReturn
ComDlg.DialogTitle = "Save to a Wave File"
ComDlg.Filter = "All Files (*.*)|*.*|Wave Files " & "(*.wav)|*.wav"
ComDlg.FilterIndex = 2
ComDlg.ShowSave
cpFileStream.Open ComDlg.FileName, SSFMCreateForWrite, False
Set Voice.AudioOutputStream = cpFileStream
Voice.Speak TextField.Text, SVSFDefault
cpFileStream.Close
Set cpFileStream = Nothing
Set Voice.AudioOutputStream = Nothing
Cancel:
Exit Sub
End Sub

Conclusion
I developed these codes to listen my thesis that helped to revise again and again. Really I enjoy it during my thesis time. For others people help I am publishing this

No comments: