etTTSSimple TTS Sample Program

TeleTools

The etTTSSimple sample application demonstrates how to use Microsoft's SAPI 5.1 Speech SDK and TeleTools with TAPI to create an application capable of Text-To-Speech (TTS).. Just some of the things you can do:

  • Select from all available telephony devices

  • Activate and deactivate devices

  • Choose a speech wave format

  • Watch Telephony and Speech events fire in the log window

  • Play Text-To-Speech during a telephone call or to your sound card

  • Popup the TeleScope utility to get even more log information and to test, debug, prototype and learn

  • Click the info button in the lower right to get more information and help

Requirements
Using This Sample Program
Download this Sample Program 
How this Sample Program Works
Source Code
Release Notes

Development Environment Technical Information
Telephony Hardware Technical Information

 

Requirements

  • Working telephone line

  • TAPI Telephony device such as a Hi-Phone, SST, Dialogic Card, PBX, voice modem, etc.

  • Installed TSP for the device

  • Microsoft's SAPI 5.1 SDK installed

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.

Using This Sample Program

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:

etPlay1.VolumeEnabled = True
etPlay1.VolumeDefault = False
etPlay1.VolumeReset = False
etPlay1.VolumePosition = 75

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:

etPlay1.SourceFileName = "10msof11kHzSilence.wav"
etPlay1.DeviceActive = True

Silence10ms11k8bitMono - 10ms of silence at 11kHz, 8-bit, Mono (Dialogic)
Silence10ms8k16bitMono - 10ms of silence at 8kHz, 16-bit, Mono (voicemodems)

 

Download this Sample Program

For Use with TeleTools v3.7

File

Purpose

EXE

Ready to run!

Borland Delphi 5,6,7

Source code

Visual Basic 5,6

Source code

Tell us what you need?

Click here and tell us what you need!

   

How this Sample Program Works

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.

Control

Description

CheckBoxActive Used to activate the TAPI Line device.
ComboBoxDevice Used to select the TAPI line device.
ButtonTeleScope When clicked the TeleScope.Visible property for the etLine control is set
   
   
ButtonHangup For hanging up all calls.
ButtonClear Clears the information in the Memo1 control
ButtonDeviceConfig Display the TAPI TSP config dialog for your hardware
ButtonInfo Popup box for getting more information from ExceleTel
Memo1 Displays the log information.

etLine1

The TeleTools etLine control

 

Event Handler Routine

Description

FormCreate

Event Handler Routine for: creation of the form. It fills the combo box with available TAPI line devices and initializes the line device and the combo box to the first device available..

FormClose Event Handler Routine for: closing of the form. The line device is closed by setting the etLine1.Device.Active property to False.
ComboBoxDeviceClick Process the device change
CheckBoxActiveClick

Event Handler Routine for: the CheckBoxActive.OnClick event for the CheckBoxActive controls. The “Active” checkbox is used to turn the selected line device on, when checked, or off, when not checked. If the control is checked, then the line device is activated by setting the property etLine1.Device.Active = TRUE; if not checked, then the line device is deactivated by setting the property etLine1.Device.Active = FALSE.

If there error LINEERR_INVALIDMEDIAMODE is returned when activating the line device, the device is probably not 100% TAPI-compliant. The etLine1.Device.MediaModesActive is set to LINEMEDIAMODE_DATAMODEM and etLine1.Device.Active is once again set to TRUE. We assume that the device is a modem that does not support the voice features, so we attempt to activate the modem in data mode.

After successfully activating the line device, the ButtonDial control is enabled. 

ButtonDialClick Event Handler Routine for: the ButtonDial.OnClick event for the ButtonDial button. The etLine1.Call.PhoneNumber property is set to the value in the EditPhoneNumber control then the etLine1.Call.Dial method is then called. If no errors occurred then the ButtonDial and ButtonDialtone controls are disabled and the ButtonHangup control is enabled.
ButtonAnswerClick Event Handler Routine for: the ButtonAnswer.OnClick event of the ButtonAnswer control. The etLine1.Call.Answer method is called then the etLine1.Error properties are tested for errors. Any error information is appended to the log edit box.
ButtonClearClick Event Handler Routine for: the ButtonClear.OnClick event of the ButtonClear control. The information in the Memo1 control (the on screen log) is cleared.
ButtonHangupClick Event Handler Routine for: the ButtonHangup.OnClick event for the ButtonHangup control which executes the etLine1.Call.Hangup method 

ButtonTeleScopeClick

Event Handler Routine for: the ButtonTeleScope.OnCLick event of the ButtonTeleScope control. This button causes the TeleScope.Visibile properties to be toggled for the etLine1control. This causes the TeleScope to be displayed or hidden.

   
etLine1CallBegin Event Handler Routine for: etLine.OnCallBegin event of the etLine control. This event is appended to the log edit box on-screen.
etLine1CalledID Event Handler Routine for: etLine.OnCalledID event of the etLine control. When the etLine.OnCalledID event fires the etLine1.Call.CalledID.Name and etLine1.Call.CalledID.Number property values are appended to the log.. This is the ID of the called party on an outbound call.
etLine1CallEnd Event Handler Routine for: etLine.OnCallEnd event of the etLine control. This event is appended to the log edit box on-screen.
etLine1CallerID Event Handler Routine for: etLine.OnCallerID event of the etLine control. When the etLine1.OnCallerID event fires, the etLine1.Call.CallerID.Name and etLine1.Call.CallerID.Number property values are appended to the log.  This displays the ID of the incoming caller.
etLine1Connected Event Handler Routine for: etLine.OnConnected event of the etLine control. The etLine1.Call.Origin is checked to see if the call is inbound or outbound.
etLine1ConnectedID Event Handler Routine for: etLine.OnConnectedID event of the etLine control. When the etLine.OnConnectedID event fires, the etLine1.Call.ConnectedID.Name and etLine1.Call.ConnectedID.Number property values are appended to the log.
etLine1Dialing Event Handler Routine for: etLine.OnDialing event of the etLine control. This event is appended to the log edit box on-screen.
etLine1Dialtone

Event Handler Routine for: etLine.OnDialtone event of the etLine control. It simply indicates in the log that this event has fired and the device reports dialtone.

etLine1Disconnected

Event Handler Routine for: etLine.OnDisconnected event of the etLine control. If ButtonDialtone had been clicked and this event occurs, then the etLine1.Call.DisconnectMode property is tested to see if the dial tone was detected. This may not work with some telephony devices because not all Telephony Service Providers (TSP) and/or telephony devices are capable of reporting a disconnect mode.

The etLine1.Call.Hangup method is called to hang up the call.

etLine1Error Event Handler Routine for: etLine.OnError event of the etLine control. The log is updated to indicate that this event has fired.
etLine1Idle Event Handler Routine for: etLine.OnIdle event of the etLine control.  The Dial button is enabled and the Hangup button is disabled
etLine1Offering Event Handler Routine for: etLine.OnOffering event of the etLine control. .
etLine1Ring Event Handler Routine for: etLine.OnRing event of the etLine control. The log edit box is updated with a message.
   
   
   

 

 

 

Release Notes

April 21, 2003

First release.