Click here to Skip to main content
11,573,408 members (55,403 online)
Click here to Skip to main content

Text-To-Speech

, 27 Nov 2001 509.5K 9.1K 66
Rate this:
Please Sign up or sign in to vote.
This is a tutorial which shows you how to create a simple program that will speak anything!

Introduction

This tutorial will show you how to create a very simple program that will actually speak! You will need to download the text-to-speech control if you have not already downloaded it.

Step 1 - Adding the controls

Firstly add a new Standard EXE project. Then change the projects name to TextToSpeech. Change the forms name to frmSpeak. Add the Direct Text-to-Speech control to the form by right clicking on the toolbox and then selecting components. Click on the Microsoft Direct Text-to-Speech item and then click OK.

Draw the Text-to-speech control on the form and set its name property to spkSpeak and its visible property to false. Next add 10 buttons. Set their names to btnNumbers and their captions to one greater than their index. Then add a text box and change its name to txtText, its text property to nothing and its multiline property to true. Add a button below the text box. Set its name to btnSpeak and its caption to Speak.

Step 2 - Declaring the constants

The next step is to add the code. This code will say the caption of the button and then run a program depending on which button you clicked. Add this code to the general declarations:

Const Notepad = "c:\windows\notepad.exe"
Const Wordpad = "C:\program files\accessories\Wordpad.exe"
Const Paint = "c:\windows\Pbrush.exe"
Const Calculator = "c:\windows\Calc.exe"
Const Volume = "c:\windows\Sndvol32.exe"
Const InternetExplorer = "C:\Program Files\Internet Explorer\Iexplore.exe"
Const SoundRecorder = "c:\windows\Sndrec32.exe"
Const Clipboard = "c:\windows\Clipbrd.exe"
Const Dialer = "c:\windows\Dialer.exe"
Const Solitaire = "c:\windows\Sol.exe"

Step 3 - The code

Now add this code under the click event of btnNumbers:

spkSpeak.Speak "You clicked button number " & btnNumbers(Index).Caption & "."

Select Case Index + 1
  Case Is = 1
    Shell Notepad, vbNormalNoFocus
  Case Is = 2
    Shell Wordpad, vbNormalNoFocus
  Case Is = 3
    Shell Paint, vbNormalNoFocus
  Case Is = 4
    Shell Calculator, vbNormalNoFocus
  Case Is = 5
    Shell Volume, vbNormalNoFocus
  Case Is = 6
    Shell InternetExplorer, vbNormalNoFocus
  Case Is = 7
    Shell SoundRecorder, vbNormalNoFocus
  Case Is = 8
    Shell Clipboard, vbNormalNoFocus
  Case Is = 9
    Shell Dialer, vbNormalNoFocus
  Case Is = 10
    Shell Solitaire, vbNormalNoFocus
End Select

Then next piece of code will speak the text typed in the text box. Add this code to the btnSpeak click event:

spkSpeak.Speak txtText.Text

This is how it works: when the button is clicked it says, "You clicked button number" and then it says the caption of the button. It then runs a program depending on which button you clicked. Also, when you type something in the text box, it reads the text and speaks it out. Your form should look something like this:

If you run the program, it should speak the caption of the button you clicked and run a program and if you type something in the text box it should speak what you typed. Have fun!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

AlexanderRegueiro
United Kingdom United Kingdom
No Biography provided

You may also be interested in...

Comments and Discussions

 
QuestionNo Sound Output Pin
Member 1063528327-Jun-15 2:42
memberMember 1063528327-Jun-15 2:42 
BugxVoice.dll is missing Pin
Farid Alkorashy23-May-14 5:53
memberFarid Alkorashy23-May-14 5:53 
Questionitalian language Pin
Member 1001284430-Apr-13 4:36
memberMember 1001284430-Apr-13 4:36 
GeneralMy vote of 5 Pin
FABUS2712-Jun-12 3:36
memberFABUS2712-Jun-12 3:36 
QuestionNot working Pin
Sjnilan13-Mar-12 7:27
memberSjnilan13-Mar-12 7:27 
QuestionPlease, send me source too Pin
Raimond S29-Nov-11 23:05
memberRaimond S29-Nov-11 23:05 
QuestionABOUT THE TEXT TO SPEECH PROJECT Pin
madhuramanojjoshi14-Jul-11 19:59
membermadhuramanojjoshi14-Jul-11 19:59 
Generalsend me the source code Pin
chintan27907-Mar-11 0:56
memberchintan27907-Mar-11 0:56 
GeneralRe: send me the source code Pin
srikantharumilli8-Sep-11 7:04
membersrikantharumilli8-Sep-11 7:04 
GeneralMy vote of 1 Pin
Naren83.Freak21-Oct-10 6:41
memberNaren83.Freak21-Oct-10 6:41 
GeneralMy vote of 1 Pin
rahuluttarkar11-Oct-10 1:19
memberrahuluttarkar11-Oct-10 1:19 
GeneralMy vote of 5 Pin
walter galotta18-Jul-10 20:47
memberwalter galotta18-Jul-10 20:47 
Generaltext to speech Pin
Member 373269320-May-10 22:28
memberMember 373269320-May-10 22:28 
GeneralNice Tutorial Pin
sankaranandan6-Mar-10 20:57
membersankaranandan6-Mar-10 20:57 
Generalsir i am geting compiler error : method or data member not found Pin
chistiforu_2k516-Dec-09 14:57
memberchistiforu_2k516-Dec-09 14:57 
GeneralNo Voice Pin
Gurinder Pal15-Dec-09 21:48
memberGurinder Pal15-Dec-09 21:48 
GeneralMy vote of 1 Pin
Kumar Umang Gupta21-Oct-09 2:17
memberKumar Umang Gupta21-Oct-09 2:17 
AnswerRe: My vote of 1 Pin
Member 415612718-Nov-09 4:23
memberMember 415612718-Nov-09 4:23 
QuestionWhat's true? Pin
beibut17-Oct-09 7:01
memberbeibut17-Oct-09 7:01 
GeneralProblem solved. Thank you Pin
johnius17-Mar-09 1:57
memberjohnius17-Mar-09 1:57 
GeneralHELP PLEASE.... Pin
Mary May26-Sep-08 19:20
memberMary May26-Sep-08 19:20 
Generalnot responding well Pin
ramcse8-May-08 6:02
memberramcse8-May-08 6:02 
GeneralNo sound Pin
BrunoCoimbra15-Apr-08 8:34
memberBrunoCoimbra15-Apr-08 8:34 
Questionno sound appear Pin
kimodiab6-Apr-08 10:11
memberkimodiab6-Apr-08 10:11 
QuestionText to Speech converter(olife) Pin
olyad25-Mar-08 3:48
memberolyad25-Mar-08 3:48 
Generalhelp: Changing voice Pin
craver064-Oct-07 16:54
membercraver064-Oct-07 16:54 
GeneralRe: help: Changing voice Pin
killer angelo17-Oct-07 6:34
memberkiller angelo17-Oct-07 6:34 
Generaltts for malay language Pin
zuwie28-Aug-07 7:12
memberzuwie28-Aug-07 7:12 
GeneralHelp Me.......... Pin
nay3315520-Jun-07 18:20
membernay3315520-Jun-07 18:20 
GeneralHele Me ..................... Pin
nay3315520-Jun-07 17:59
membernay3315520-Jun-07 17:59 
GeneralPashto text speech Pin
Wahab Banusey17-Jun-07 21:53
memberWahab Banusey17-Jun-07 21:53 
NewsVB6 Application Terminates on Win2K3 Pin
meaningoflights23-May-07 15:58
membermeaningoflights23-May-07 15:58 
Generalarabic text to speech Pin
Member #382346912-Feb-07 21:33
memberMember #382346912-Feb-07 21:33 
GeneralRe: arabic text to speech [modified] Pin
Wahab Banusey17-Jun-07 21:38
memberWahab Banusey17-Jun-07 21:38 
GeneralRe: arabic text to speech Pin
jatin288227-Jun-07 5:52
memberjatin288227-Jun-07 5:52 
QuestionHow can I create a package for install Pin
soloc20-Oct-06 8:52
membersoloc20-Oct-06 8:52 
GeneralTyping contents of letter Pin
vbone29-Sep-06 20:23
membervbone29-Sep-06 20:23 
Generaltext to speach Pin
vbone29-Sep-06 19:36
membervbone29-Sep-06 19:36 
GeneralRe: text to speach Pin
rakesh saklecha21-Feb-07 1:42
memberrakesh saklecha21-Feb-07 1:42 
GeneralText to speech Pin
rohit_srms28-Aug-06 20:49
memberrohit_srms28-Aug-06 20:49 
Questiontext to speech in hindi language Pin
deepaksahdev7-Aug-06 3:37
memberdeepaksahdev7-Aug-06 3:37 
QuestionRe: text to speech in sinhala language Pin
S_JAYASURIYA8-Feb-07 6:26
memberS_JAYASURIYA8-Feb-07 6:26 
Generalhi!!! Pin
AinJheL_mi28-Jun-06 0:03
memberAinJheL_mi28-Jun-06 0:03 
GeneralThank You. Pin
pianoabby14-Apr-06 13:29
memberpianoabby14-Apr-06 13:29 
QuestionMoving the lips? Pin
JeppeGHJHGJGJhg5-Mar-06 2:44
memberJeppeGHJHGJGJhg5-Mar-06 2:44 
Generalvoice recogntion Pin
megace13-Dec-05 15:31
membermegace13-Dec-05 15:31 
Generalanother help Pin
sweetaple27-Oct-05 18:13
membersweetaple27-Oct-05 18:13 
GeneralTHE TEXT-TO-SPEECH VB SAMPLE Pin
Liveson22-Oct-05 4:44
memberLiveson22-Oct-05 4:44 
GeneralRe: THE TEXT-TO-SPEECH VB SAMPLE Pin
Peter Carnegie9-Nov-05 23:05
memberPeter Carnegie9-Nov-05 23:05 
GeneralRe: THE TEXT-TO-SPEECH VB SAMPLE Pin
tivr1-Feb-06 8:00
membertivr1-Feb-06 8:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150624.2 | Last Updated 28 Nov 2001
Article Copyright 2001 by AlexanderRegueiro
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid