NOTE: You must download and install SAPI 5.1 from HERE. XP users - XP comes with 5.0 of SAPI and does not include the Microsoft Mary and Mike voices. The LH voices do not work with the default engine. Go into the Speech section of the control panel and set your default voice to a Microsoft voice instead for the purposes of testing this sample.
As soon as the program loads, click on the "Speak to Sound Card" button and listen to the text in the bottom window played as text-to-speech to your default audio device.
Next, make sure your device is connected to an active telephone line. Select your TAPI telephony device from the "ComboBoxDevice" list. Then check the active checkbox to activate your device. You will see events fire in the "call progress" memo box window and will see the etLine.DeviceActive property set to true. Either select the default, or if you know the specific wave format preferred by your device, select it from the ComboBoxWaveFormat combo box. Place an incoming call to the line you activated. You will see the call progress events firing such as OnOffering, OnCallBegin and OnRing. These events will show you where to put your code to program your own application that calls methods, sets and views properties and responds to events.
Once the sample program detects the OnOffering event, it will enable the answer button so that you can press it to answer the call. You will see the OnConnected event fire as TeleTools reports to you that your call is now in the conneced state and the text in the bottom window will be spoken as speech across the phone line. Speech events such as OnSentence and OnStartStream will be displayed.
You can try different wave formats and press the "play again" button if you want to see what your device supports. The higher the sampling rate, the better the quality. This is easy to test using the sound card by choosing the first and lowest quality sample, and then selecting a much higher quality sample such as 22kHz8bitmono. Keep in mind that not all devices support more than one format or higher quality formats. In addition, a regular analog telephone call is limited in bandwidth to about 400 to 3500Hz. Therefore anything sampled above 8kHz is wasted effort. That's why most voice modems default to 8kHz16BitMono, the highest quality useful.
Windows has the ability to use CODECS, which allow many devices to play and record formats other than are native to them, your processor is then used to compress and decompress the audio files into a format which is then processed through the card. Due to the processor intensive nature of speech and wave files, even if your device will work with a wave format not listed in it's specification, you should always choose your devices default format. For more information, please see our "working with modems" white paper and the technical information on your hardware.
When you are through with your call, you can click on the "hangup" button to end the it and press the "clear log" button to clear the Call Progress window and try again. There is a "Line Config" button that will display the device configuration screen for the TSP (terminal service provider) or driver for your device if it supports this function and a "Stop" button to stop the speech before it is done playing.
In addition, there is the TeleScope button which brings up our extremely powerful diagnostic, prototyping and learning too. You can see even more information about the progress of your call and try things that aren't built into the sample such as trying an outbound call. We can't stress enough the power of using TeleScope to see exactly where you are and how to get where you want to go.
Lastly, their is our little info button to call up an about box that will provide more information, a link to this web page for help, and ways to contact us.
If you run into any errors, you can usually just deactivate the device and reactivate it again to continue. If your device is not listed in the device list, then the TAPI TSP for your device is not properly installed. Make sure you have the latest drivers and have installed them properly. If you have any trouble, just give us a call or send us an email using the form above in the support menu or by clicking here GET SUPPORT.
With TeleTools TAPI tools and SAPI, you can create powerful text-to-speech applications such as voice mail, IVRs, card processing centers, speaking callerID, systems for the sight impaired and just about anything where you want to be able to create spoken audio from text across a phone line.
NOTE ABOUT VOLUME (especially Dialogic users)
Some devices have issues with volume. In particular, Dialogic has a bug in their wave driver which does not report the volume level properly, it is always zero (0). Therefore, making sure you put the following lines into your application will make sure to not save and reset a default volume which can wind up making your audio so low you can't hear it. In addition, you may need to use the little trick below to set the volume if it gets set too low:
Then, in order to actually set the volume since you aren't using etPlay to play a wave file, but instead using SAPI to play text-to-speech, you must create a very small wave file containing silence. We've included one on this page for you to use. Then on a connected call, use the following code to send this wave file to your hardware to reset it's default volume:
For Use with TeleTools v3.7
The program uses the controls events and subroutines listed below. You get your device list simply by using the etLine.Device.List property and the etLine.Device.ID property. We automatically find the installed TAPI devices for you and let you select and then activate the device with the etLine.DeviceActive property.
Once you have selected your device, we find the associated wave devices for that device for you and let you access them with the etLine.WavePlayID property. We create a data object to hold the wave format constants and populate the ComboWaveFormat box with them. We set MMSysAudioOut1.Format.Type to the wave format selected and then we then set the MMSysAudioOut1.DeviceId to the etLine.WavePlayID so that speech can be output to our selected device in the correct format.
The SAPI Voice1 object is created along with the MMSysAudioOut1 object which holds the device we want to send the speech to. We then set the Voice1.AudioOutputStream to the MMSysAudioOut1 device and we are ready to speak using the Voice1.Speak method!
Most of the other buttons operate just as simply with only one line of code. The hangup button calls the etLine.Call.Hangup method and the TeleScope button sets etLine.Telescope.Visible to true. The Line Config button calls the etLine.Device.Config function.
All of the logging is done with our many events and properties and is also incredibly simple when you see the code. When an incoming call is connected, the OnOffering is usually one of the first events to fire, depending on the device, followed by the OnCallBegin event. This lets you track the progress of the call. We just write a line of text to the screen in each of these event handlers. We respond to the OnRing event and display.
The OnCallEnd event fires when the call has ended and then the OnIdle event will fire to let you know the device is ready to make another call.
April 21, 2003