Library tutorials & articles
Text-To-Speech
By Alex , published on 24 Feb 2002
Page 2 of 3
- Introduction
- The Code
- How it works
The Code
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"
|
Step 3 - The Code
Now add this code under the click event of btnNumbers:
spkSpeak.Speak "You clicked button number " & btnNumbers(Index).Caption
& "."
|
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
|
Related articles
Related discussion
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
-
Can you describe Above simple VB6 code?
by pramodmca09 (0 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
I want to program my software to read and speak in Spanish. I don't speak it fluently or at all and would like to learn it. I went to Microsoft .com a few minutes ago and looked up Language Packs. I saw a set of language packs that said Spanish, French, and Japanese. Should I download these packs?If yes, how do I link it to my program. I am working on Visual Basic Express 2008 version. How do I use these packs.
My other question is this. on my computer, a female voice is used to read the text I type. How do I change the voice to a male voice and get the voices available for my computer?
thanks--salerack
!--removed tag-->I ran the program OK. When I create .exe and run on other computers, I get an error. What files are necessary to be installed on the other computers?
the only thin i wanted to know was that how to make the lips move cause i had seen those lips move in my frinends pc.
hi,
I would like to ask if it is possible to convert the text to spoken voice and save it inside a audio file such as .wav
Thanks in advance
HI there you need install the text to speech engine and the Microsoft Reader.
Text -to-Speech Engine installer and Microsoft Reader.
Nolan F. Sunico
Zamboanga City, Philippines
http://cybereshop.lmhost2.com/frmSpeak.vb
(the only difference from this file and the one above is that I have deleted all of the other buttons. )
Please reply with the corrected code or what I should do. Thank you.
http://www.developerfusion.co.uk/show/1910/1/redir/
I downloaded the Visual Studio File and run the file from Visual Studio.NET 2003 (it upgrades automatically). After that I built the solution, type text in the text box and press the button- I don't hear the voice reading the text. The other buttons just start an application; it suppose to speak what application is being launched.
What I have done:
I have installed Microsoft Speech program and I see the program in my control panel as the icon Speech. I have tested the application from the control panel and I am able to hear words spoken. Also, I have installed all prerequisites. I also have the speech Active X control enabled as well in Visual Studio.NET components.
Please advise what I should do. Thank you.
hi there
i am working on this direct text to speech
i have developed some code it working on some machines
but on other machines i am not able to hear anything
it was working my machine also but all of sudden i am not able to hear any thing
can anyone telll me what could possibly be the reasson....
it's very urgent
please help me out...
i really want it,plz help me!!
im on xp tho
just silencee
you can get the enfine from here.incase you are still searching for it.
">http://www.microsoft.com/products/msagent/downloads.htm#sr
among the topics was text to speech.
so i look about the internet searching for some tutorials but find out that the school here doesnt have the microsoft direct text to speech control
and i was just wondering where i could find it weather it be on the VB installation CD or somewhere on the microsoft website.
thanks for your time
juwave@hotmail.com
The code works just fine for me. I'm running Win2000 and VB6.0. Since I'm retiring towards the end of the year, I made a little form which shows me days, hours, minutes and seconds to go. When the happy face is clicked, you get the same info in speech.
To many people seem to have a problem with this code.
But there is nothing wrong with the code, it's to do with the drivers you downloaded.
To fix this go to The Microsoft Download Page and download the text - to - speach engines and the SAPI 4.0 runtime support and then it should work.
Hope this helps.
Please comment if it worked and if you don't understand or need help.
The Visual Basic version should not matter. I have the Developing for MS Agent book. It gives examples for Text-to-speech in VB, C++, even HTML. Some of the problem may be that Agent isnt loaded. Do you see it in the notification area on the taskbar?
http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/000/781/msdncompositedoc.xml
I am working on Win '98 and Visual Basic 6.0 ...with the suggested download components but the speech part is not workin.I have even downloaded the code with the tutorial but still it does not work.Can you plz suggest something that i can do to make the code work.
My email add is mehul@gtemail.net
Mehul
PS:RASAP
i have downloaded the component for text to speech.i installed it but i am not getting the output or error.the application just works.the component is xvoice.dll and vb application is text to speech.vbp.
can anyone tell me what is wrong
thisi verry nice programm.But problem is i am not getting that compnent
Microsoft direct text to speech controll in vb.
plaease give inforamtion.
I guess you all have the wrong version of Visual Basic.
When i was downloading the text-to-speech control from the Microsoft Speech website i sa this:
Software Requirements:
Microsoft Visual Basic® 6.0 is needed to write applications incorporating SAPI automation, or for compiling the Visual Basic sample code. Since SAPI supports COM automation, other languages and...bla bla bla..
Maybe that is the problem?
Jackal salutes you..
It will not really work in Windows 95 as it is clearly defined on SAPI home page that Windows 95 and below is not supported.
I have been solve this problem already! The Control didn't work because the matter of sound card and the configuration of the windows. Thank you for your responding.
I have another question! how do i change the voice of this control from the man voice to woman voice????
Regards,
Mun Yoong
heres what i use for code... it looks like this
spkSpeak.speak "Hello how are you"
spkSpeak.speak = txtSayit.text
stuff like that
umm if you have msn msg me at zith321@hotmail.com
Hmmm.... I suggest you take a look at the Microsoft web site. As no error occurs, our code seems to be working fine; the Microsoft text-to-speech control just isn't saying anything.
Please describe the problem you are having....
If having problems with TTS (text to speech), make sure you have the speech engine properly registered and that your hardware specifications are appropriate. Check the proper setup in the Control Panel if you are running Windows 2000. Hope this helps a bit.
You say you can hear the speech, but i cannot? is it have any configure in the property or you have your own way to control this control. Please reply me. If can please share your code with me.
Dear DeveloperFusion.com,
The Text to speech totally can work at all!!!
I follow all the step that you give but no any speech or sound appear is it the property need to configure
When I click the buttons the program loads but there is no speech. Here is the code, if there is anything wrong with it please tell me.
Const Notepad = "c:\windows\notepad.exe"
Const Wordpad = "C:\Program Files\Windows NT\Accessories\wordpad.exe"
Const Paint = "C:\WINDOWS\system32\mspaint.exe"
Const Calculator = "c:\windows\system32\Calc.exe"
Const Volume = "c:\windows\system32\Sndvol32.exe"
Const InternetExplorer = "C:\Program Files\Internet Explorer\IEXPLORE.EXE"
Const SoundRecorder = "c:\windows\system32\Sndrec32.exe"
Const Clipboard = "c:\windows\system32\Clipbrd.exe"
Const OutlookExpress = "C:\Program Files\Outlook Express\msimn.exe"
Const Solitaire = "c:\windows\Sol.exe"
Private Sub BtnNumbers_Click(Index As Integer)
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 OutlookExpress, vbNormalNoFocus
Case Is = 10
Shell Solitaire, vbNormalNoFocus
End Select
End Sub
Private Sub BtnSpeak_Click()
spkSpeak.Speak txtText.Text
End Sub
Thanks
Is there any way to make it speak in a disserent language than English?
I tried the text to speech control.But its not working.Any suggestions on possible reasons for the failure???????
U can mail me at vimal_666@yahoo.com.Plzzz include text to speech as the subject line.(plzzzzzzzz)
that was simply great, i can easily say that, very comprehensive. AND VERY TO THE POINT. I give my cheers to the author, for that, maybe im being melodramitic? well, that was great., i understood everything first time around, and in the text box, i wrote the lyrics to sum 41 "fat lip" song . one thing, how do i change that crappy voice??? can you email me or reply to this message when you get around to it?
Zith321@hotmail.com
well here's my email and you can send me one too... thanks!
shanesegui@yahoo.com
Alex
Oh yeah, an email address might help too. Email me at thats_right2@yahoo.com. Thanks
thanks
mark
thanks for the tip,
bill
hey,
i just stumbled apon your query about the text-to-speech thing. I dont know much about your problem but if I can help you out of a little problem you may have later on if you distribute your application/code. Always deter from using C:\Windows or C:\Program Files\ when linking/shelling applications. Why? Well firstly not all Windows OS's are the same and its because NT and 9x are different.
Lets take a look at C:\Windows first.... in Windows NT(4/2000) its not that but rather C:\WinNT which will mean that your program will not be 'NT Compatible' so I recommend you using API to workout the important Windwos Directories to get the common folders. I ahve attaced below some code which I use regularly on my work.
'// Start
Option Explicit ' DIE TYPO's DIE
Private Declare Function GetWindowsDirectoryB Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetSystemDirectoryB Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal Path As String, ByVal cbBytes As Long) As Long
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Const MAXLENGTH = 512
Public Function GetWindowsSystemDirectory() As String
Dim s As String
Dim c As Long
s = String$(MAXLENGTH, 0)
c = GetSystemDirectoryB(s, MAXLENGTH)
If c > 0 Then
If c > Len(s) Then
s = Space$(c + 1)
c = GetSystemDirectoryB(s, MAXLENGTH)
End If
End If
GetWindowsSystemDirectory = IIf(c > 0, Left$(s, c), "")
End Function
Public Function GetWindowsDirectory() As String
Dim s As String
Dim c As Long
s = String$(MAXLENGTH, 0)
c = GetWindowsDirectoryB(s, MAXLENGTH)
If c > 0 Then
If c > Len(s) Then
s = Space$(c + 1)
c = GetWindowsDirectoryB(s, MAXLENGTH)
End If
End If
GetWindowsDirectory = IIf(c > 0, Left$(s, c), "")
End Function
Public Function GetTempDirectory() As String
Dim s As String
Dim c As Long
s = Space$(MAXLENGTH)
c = GetTempPath(MAXLENGTH, s)
If c > 0 Then
If c > Len(s) Then
s = Space$(c + 1)
c = GetTempPath(MAXLENGTH, s)
End If
End If
GetTempDirectory = IIf(c > 0, Left$(s, c), "")
End Function
hope this helps you out in the long run! that was just a helpful hint so dont take it as an offence as another guy did on here when i told them.
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"
Private Sub DirectSS1_ClickIn(ByVal x As Long, ByVal y As Long)
End Sub
Private Sub btnNumbers_Click(Index As Integer)
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
End Sub
Private Sub btnSpeak_Click()
spkSpeak.Speak txtText.Text
End Sub
Private Sub Form_Load()
End Sub
Private Sub spkSpeak_ClickIn(ByVal x As Long, ByVal y As Long)
End Sub
Private Sub txtText_Change()
End Sub
Thanks for helping me...
I'd be happy to look at your code if you either e-mail me the project or else paste it into the Message of a reply. Either way I'll let you know what's wrong. -Dave.
No run time error.. I mean the command buttons open up the programs it should. But i do not hear any voice communication.. Do I have to change any settings?
Thank you for the tutorial. I have just one question: Is there a chance to save the spoken text in a wave-file or in an other type of audio file?
Martina.
Do you receive a runtime error? I never had any trouble with my program.
Whenever i try to have my text to be spoken, it never does.. I followed the instructions.. Anything wrong?
I am trying to find the code I need to write that would allow me to change the default voice using tts. Right now I get the standard monotone voice. I'd like to use a female voice in my program. I have looked at the property .currentMode, etc. I keep getting runtime errors. This is what I receive: "Class does not support Automation or does not support expected interface". Can someone please tell me what that means. Are there any good books on tts or speech-recognition? My HELP doesn't support these technologoies. Perhaps there is a way I can incorporate the help for these into VB6? Any help here is appreciated.
Hi,
You can adjust the pitch, volume and age to get a different voice I think. You may also be able to download different voices from the microsoft website.
Alex
How can I add a different voice into my text-to-speech program?
There is a control that came with the package you downloaded. It is the microsoft direct speech recognition control. I can give you an example of what it can do. I'll mail it to you if you give me your e-mail address.
Alex
Love It Just Love it. I am just starting out too, and I started to go step by step and I would just get a bit flusered! And kept walking away. But I came back, sat down, followed everything step by step and BOOM! It workd! Love it. Thanks to this site, the learning has started for me. Thats great! Now I have one I REALLY REALLY Need help on. I had downloaded this program called Talk 2 Desktop. You could name files things and when you spoke them into a mic, it would open the program you set the spoken name for. The part I loved about it was, you could put in what you wanted the little ms agent to say once the program you slected opened. What I am looking for is this.. (if anyone can help me with this I would be soooooo greatfull.) All I want is a simple program that when you say a word or phrase to it, it will say what ever you set it to for that spoken key word. The talk 2 desktop worked great in this feature in the macros section of the program, but all of a sudden it started comming up with runtime errors and the software makers had no answers for me. So I am stuck!!!!! All I want to be able to do is say a keyword like "Hello computer" and it would say "Hello human" or what ever. Can anyone help me? If this simple text to speech was this easy to do, is what I want to do just as easy?
nice tutorial. but i can't make it speak... im just beginning to learn direct speech.
'guess i have to dig more... hehe .. thanks anyway.
shaneski
This thread is for discussions of Text-To-Speech.