Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need VBA to convert Text to Speech for audible messages 7

Status
Not open for further replies.

Dor100

Technical User
Apr 9, 2001
279
US
I've been searching Google to no avail so far. Are there any VBA commands in Acc XP by which I can cause text to be converted to speech in order to give audible messages to users? Or do people know of any free downloadable utilities for this?
 
I just set a ref to Microsoft Speech Object
Library, but still the same error.
 
There are a variety of options for "Text to Speach" availale in the Win systems. There are others mentioned here (Tek-Tips) which work for me. From the smattering of what I saw, this approach instantiates an external app (or applet), slowing the actual process a bt more than I would tolerate in a production app.

I have used one of the functions found here (Tek-Tips) in a production app. It is used in contion with a bar code scnner, as a feedback mechanisim to the bar code scanner operator to let them know what data field they have filled in with the scanning and wheather the identification of the item is complete or if there was an error in the scan process. The app is a varriation on inventory counting and receiving where the operator(s) use wireless scanners and may be not in sight of the monitor when scanning. The scan procedures always require two fields to be identified and read by the scanner and may require a third, but the order of the scans is not fixed, so the operator(s) need the feedback. In general, the voice feedback occurs in less than one second, and they complain about this delay ALL THE TIME.




MichaelRed


 
Come on people now, smile on your brother - everybody get together, try to love one another right now!"

[smile][hourglass][smile]

Happy days are here again, fellow Tek-Tipsters:


*************************

Runs in Acc XP on Win 2K:

----------------------------------------------

Sub demoTTS()

'Declare and create an Excel object.
Dim XL As Excel.Application
Set XL = CreateObject("Excel.Application")

XL.Speech.Speak "Welcome to my presentation."
XL.Speech.Speak "This is an example of how to create an Excel Application object."
XL.Speech.Speak "We can use Excel's object model to invoke Text to Speech."

'Close the Excel object and set the object to nothing.
XL.Quit
Set XL = Nothing

End Sub

----------------------------------------------

I've said it before and I'll say it again: Thank God for this forum.
 
Well, I have to admit the delay in the text-to-speech activation is substantial with the method I've been able to use on Win 2k, especially in the the On Open event, and I wonder if it's any better using the method posted by FancyPrairie. If so, I still doubt there's not some way out there to tweak things to enable Win 2k to use the "SAPI.SpVoice" code. Nonetheless, I'm still very grateful and glad to have a viable way of doing this on Win 2k.
 
If you want things to be faster, how about early bound instead of late bound? But this will require adding a reference to the correct library.
 
I'm afraid I really don't know what you mean, ESquared. Normally I might understand you to be recommending placing code before the On Open event, which I doubt would make a difference here, but when you include the part about the library I'm completely unclear about what "early bound instead of late bound” means. What do you mean, and what library should be referenced?
 
early bound is when you declare an object of that object's particular type:

Code:
Dim V as SAPI.SpVoice
Set V = New SAPI.spVoice
V.Speak "blah"

In order for this to work, go to the Visual Basic window and press F2 or select Project | References and find whatever the name is of the thing that provides the SAPI name. The advantage is that because the type of object is known at compilation time, things go faster, and the loading hit is taken at startup instead of at object instantiation.

The late-bound method which FancyPrairie suggested declares objVo as a generic Object. It's slower, but it has the advantage that you don't have to have a reference... it checks to see if the object is creatable at the time you do CreateObject.

This is all very basic programming stuff and if you want more help, I'm sure that searching the web will provide hordes of information.

In the Excel example, the coder curiously used a mix of early and late bound. I'm not sure if that was intentional or not. But instead of using CreateObject once XL was declared as Excel.Application, just use the Set XL = New [ObjectType]. Unless you are trying to get a copy of Excel that is already running and you need to use GetObject.

VB also has the convenient syntax:

Code:
Dim V as New SAPI.SpVoice
V.Speak "blah"

V isn't actually instantiated until the Speak line, but because of the way it was declared, it automatically creates it at this time. If you set V to nothing afterward, and then use V again, it will be transparently instantiated again.
 
ESquared said:
" ... find whatever the name is of the thing that provides the SAPI name ... "

... and the secret word is ... ?



MichaelRed


 
er, F2 was the wrong thing, it's Tools-References only.

And to answer your question, a little poking reveals that it is at C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll. In the references dialog, click Browse and select it. I didn't actually try it, though.

How'd I find that out? Well, I searched my hard drive for "sapi" and found sapi.inf, which I looked in and this pointed me to the Microsoft Shared folder.
 
[bold]ESquared[/b],

Thanks,

I attempted to search my systems, both at home and at work. At home, I found the string only in the registry, and even that took a while. I didn't see any of those pointing to a .dll, so went on to other persuits. At work, I first attempted the local worstation, alas to no avail and a bit more time. Feeling bold and brave (if not beautiful) I (foolishly) tried the search on the domain. OOPS (slop, mop and spoon!!!),

Given the reference, I will again attempt to locate this critter!

MichaelRed


 
OOPS ==> a large domain ==> a Veeeeeeeeeeeeeeeeeeery long search.



MichaelRed


 
Works for me to... using access 2000

Function speech(str As String)
Dim objVo As Object
Set objVo = CreateObject("SAPI.SpVoice")
objVo.Speak str
End Function

call this with..
speech("o no, this is sending me crazy!")
or whatever you want it to say

Slight variation to fancy praries coding.




Ian Mayor (UK)
Program Error
Programmers do it one finger at a time!
 
HI..
I have been following this thread..

I have W2K and Access2K Normal Loads SO I did not have the speech engine.

I went to Microsoft and downloaded the SpeechSDK5.1
installed it,copied the Help file, and set the reference to the Speech Object Library.

My Access programs now have speech without the Excel interface.

Hope this was helpful...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top