I don't know what component you're talking about. Maybe it's
an OCX in XP because of SAPI5 being built in. But if you're
using SAPI 5 you just need a reference to SAPI.DLL:
"Microsoft Speech Object Library"
I'd be inclined to connect it with a button rather than form load,
just to rule out other unforseen problems - since you probably don't
want your program talking while it's loading anyway.
Also, you'll find samples in the SAPI SDK. (Big download. You'll
need to have or borrow a high speed connection.)
Note that support for SAPI5 is only in XP. The minimum shipping
support size for other systems is 6-10 MB worth of DLLs, etc. and it's
rigged not to run on Win95.
'-- The Enums:
Enum SpeechVoiceSpeakFlags
SVSFDefault = 0
SVSFlagsAsync = 1 '--speak asynchronously.
SVSFPurgeBeforeSpeak = 2 '--purge pending speech.
SVSFIsFilename = 4
SVSFIsXML = 8
SVSFIsNotXML = 16
SVSFPersistXML = 32
SVSFNLPSpeakPunc = 64 '--speak punctuation as word: "blah blah period"
'-- Masks
SVSFNLPMask = 64
SVSFVoiceMask = 127
SVSFUnusedFlags = -128
End Enum
'-- This flag may not be what you want but it's a sanmple.
'-- It will make TTS keep up with events rather than finish speaking it's
'-- buffer before moving on. For instance, if you set it to speak 500
'-- names and then tell it halfway through to speak 500 numbers instead,
'-- ASync will cause it to stop reading names and switch to numbers.
'-- Not-Async will cause it to finish with the names first.
Const SPEAK_FLAGS_1 = SVSFlagsAsync Or SVSFPurgeBeforeSpeak Or SVSFIsNotXML
Public SpkVoice As SpVoice
'-- Public sub that can be called to speak provided string:
Public Sub SpeakIt(sText As String)
On Error Resume Next
If (Len(sText) = 0) Then Exit Sub
SpkVoice.Speak sText, SPEAK_FLAGS_1
End Sub
--
--
Chris <c9*****@hotmail.com> wrote in message
news:f3***************************@news.multikabel .nl...
Hi,
I am running VB6 under windows XP Professional.. I added the 'Microsoft
Direct Text-To-Speech' component, named it spkSpeak and added the
following code in Form(Load): spkSpeak.Speak "You have selected Microsoft Sam.".
The weird thing is that when I run the program nothing happens.
Microsoft Sam is automatically installed when windows is installed, there
must be some way to use this function. Does anyone here knows how it can
be used in a VB application? (preferably without installing other programs)
Thanks,
Chris