etTextToSpeech Sample Program Source CodeNOTE: This sourcecode is uncommented here, but complete commented code is including it the downloadable project. To see Delphi Source, click HERE ********************************************************************************** '************************************************ '
Form_Load '************************************************ Private
Sub Form_Load() On Error GoTo ErrHandler etLine1.Enabled = True etPlay1.Enabled = True etRecord1.Enabled = True bFromFormLoad = True Set spVoice1 = New SpVoice spVoice1.EventInterests = SVEAllEvents Set MMSysAudioOut1 = New SpMMAudioOut etLine1.DeviceIdleDelay = 3000 TextPhoneNumber.Text = etLine1.CallPhoneNumber ComboBoxDevice.Clear etLine1.DeviceId = 0 ComboBoxDevice.AddItem
etLine1.DeviceList(L) Next L If ComboBoxDevice.ListCount > 0 Then ComboBoxDevice.Text =
ComboBoxDevice.List(0) End If ComboBoxDevice.ListIndex = 0 ComboBoxWaveDevice.AddItem
etPlay1.DeviceList(W) Next W If ComboBoxWaveDevice.ListCount > 0 Then ComboBoxWaveDevice.Text =
ComboBoxWaveDevice.List(0) End If ComboBoxWaveDevice.ListIndex = 0 ' point to first device
For X = wfUnknown To wfIMAADPCM08000M04 etRecord1.SourceFormatID
= X ComboBoxWaveFormats.AddItem
etRecord1.SourceFormatName Next X If ComboBoxWaveFormats.ListCount > 0 Then ComboBoxWaveFormats.ListIndex
= 3 iLastGoodFormat = 3 End If
WriteLog ("Enumerating Voices...") Dim Token As ISpeechObjectToken For Each Token In spVoice1.GetVoices ComboBoxVoices.AddItem (Token.GetDescription()) Next ComboBoxVoices.ListIndex = 0 WriteLog ("Enumerated Voices") WriteLog ("About to check
attributes...") SliderSpeechRate.Value = spVoice1.Rate LabelRatePos.Caption = Str(SliderSpeechRate.Value) SliderVolume.Value = spVoice1.Volume LabelVolumePos.Caption = Str(SliderVolume.Value) WriteLog ("Rate = " &
Str(SliderSpeechRate.Value)) WriteLog ("Volume = " &
Str(SliderVolume.Value)) WriteLog ("Checked attributes") iSpeechFlags = SVSFlagsAsync Or
SVSFPurgeBeforeSpeak Or SVSFIsXML ComboBoxWaveDevice.ListIndex = 0 bFromFormLoad = False cmdButtonHangup.Enabled = False cmdButtonAnswer.Enabled = False Exit Sub ErrHandler: MsgBox
"Error in initialization: " & vbCrLf & vbCrLf &
Err.Description & _ vbCrLf & vbCrLf &
"Shutting down.", vbOKOnly, "TTSApp" Set spVoice1 = Nothing Set MMSysAudioOut1 = Nothing End End
Sub '***************************************************************************** '
CheckBoxActive_Click - Activate and Deactivate the TAPI Line device '***************************************************************************** Private
Sub CheckBoxActive_Click() If CheckBoxActive.Value = 0 Then If etLine1.DeviceActive
Then WriteLog
("Deactivating the device...") cmdButtonStop_Click etLine1.DeviceActive
= False If
Not etLine1.DeviceActive Then
WriteLog ("etLine1.Device.Active = False")
cmdButtonDial.Enabled = False
ComboBoxWaveDevice.Enabled = True
cmdButtonSpeak.Enabled = False Else
WriteLog (vbTab & "Error = " & etLine1.ErrorText)
CheckBoxActive.Value = 1 End
If End If Else If Not
etLine1.DeviceActive Then cmdButtonHangup.Enabled
= False WriteLog
("Activating the " & etLine1.DeviceName & "
device...") etLine1.DeviceActive
= True If
etLine1.ErrorNumber = INVALID_SERIAL_NUMBER Then
MsgBox ("Error opening line device: " &
etLine1.ErrorText & vbCrLf & vbCrLf & _
"See the help topic:" & vbCrLf & vbCrLf & _
vbTab & "Why Serial Numbers Are Important") End
If If
(Not etLine1.DeviceActive) And (etLine1.ErrorNumber =
LINEERR_INVALMEDIAMODE) And _
(InStr(1, etLine1.TAPITSP, "Modem", 1) > 0) Then
etLine1.PrivilegeNone = True 'set proper priviledge for
incompatible modems
etLine1.DeviceActive = True
MsgBox ("The program has detected that your device is a
(" + etLine1.DeviceName & _
") DATA modem and therefore has no voice capabilities."
& vbCrLf & vbCrLf & _
"We will now force a compatibility mode in order to allow you
to " & _
" continue while greying out options your modem may not
support." & vbCrLf & vbCrLf & _
"This device will be able to:" & vbCrLf & vbCrLf
& vbTab & "DIAL" & vbCrLf & vbCrLf & _
"If you think you have a voice modem, expected more
functionality, " & _
"or other programs provide more functionality with this modem,
see the " & _
"topic 'Working with Modems' in the Appendix of the TeleTools
help file.") End
If If
etLine1.DeviceActive Then
WriteLog ("etLine1.Device.Active = True")
cmdButtonSpeak.Enabled = False
cmdButtonDial.Enabled = True
ComboBoxWaveDevice.ListIndex = etLine1.WavePlayID
ComboBoxWaveDevice_Click ' force OnChange event
ComboBoxWaveDevice.Enabled = False Else WriteLog
(vbTab & "Error = " & etLine1.ErrorText)
CheckBoxActive.Value = 0 End
If Else WriteLog
("There is a problem, check your device!") CheckBoxActive.Value
= 0 End If End If End
Sub '***************************************************************************** '
ComboBoxDevice_Click -
Process device change. If no
errors, then device is '
TAPI compliant so set privileges accordingly '***************************************************************************** Private
Sub ComboBoxDevice_Click() If bFromFormLoad Then Exit Sub CheckBoxActive.Value = False etLine1.DeviceId = ComboBoxDevice.ListIndex WriteLog ("etLine1.DeviceName = " &
etLine1.DeviceName) CheckBoxActive_Click If etLine1.ErrorNumber <> 0 Then WriteLog (vbTab &
"Error = " & etLine1.ErrorText) End If End
Sub '***************************************************************************** '
ComboBoxWaveDevice_Click - Change the wave output device '***************************************************************************** Private
Sub ComboBoxWaveDevice_Click() Dim fFormat As ISpeechWaveFormatEx On Error GoTo ErrHandler If bFromFormLoad Then Exit Sub If CheckBoxActive.Value = 1 Then MMSysAudioOut1.DeviceId =
etLine1.WavePlayID Else MMSysAudioOut1.DeviceId = ComboBoxWaveDevice.ListIndex End If WriteLog ("Audio Out = " &
ComboBoxWaveDevice.Text) etRecord1.SourceFormatID =
ComboBoxWaveFormats.ListIndex Set fFormat = New SpWaveFormatEx fFormat.FormatTag = etRecord1.SourceFormatTag fFormat.Channels = etRecord1.SourceFormatChannels fFormat.SamplesPerSec =
etRecord1.SourceFormatSamplesPerSec fFormat.AvgBytesPerSec =
etRecord1.SourceFormatAvgBytesPerSec fFormat.BlockAlign =
etRecord1.SourceFormatBlockAlign fFormat.BitsPerSample =
etRecord1.SourceFormatBitsPerSample Call
MMSysAudioOut1.Format.SetWaveFormatEx(fFormat) WriteLog ("Source.Format = " &
etRecord1.SourceFormatName) WriteLog ("Source.Format = " &
MMSysAudioOut1.Format.Type) spVoice1.AllowAudioOutputFormatChangesOnNextSet =
False Set spVoice1.AudioOutputStream = MMSysAudioOut1 iLastGoodFormat = ComboBoxWaveFormats.ListIndex WriteLog ("etLine1.DeviceID = " &
Str(etLine1.DeviceId)) If etLine1.ErrorNumber <> 0
Then WriteLog (vbTab &
"Error = " & etLine1.ErrorText) End If Exit Sub ErrHandler: Dim myError As String myError = Err.Description WriteLog ("Set audio output error:
" & myError) If Left(myError, 24) = "Method 'SetWaveFormatEx'"
Then MsgBox ("Bad Wave
Format... Try Another!") ComboBoxWaveFormats.ListIndex
= iLastGoodFormat End If End
Sub '***************************************************************************** '
ComboBoxVoice_Click - Change the speaking voice '***************************************************************************** Private
Sub ComboBoxVoices_Click() Dim SOTokenVoice As ISpeechObjectToken Set SOTokenVoice = spVoice1.Voice Set spVoice1.Voice =
spVoice1.GetVoices().Item(ComboBoxVoices.ListIndex) WriteLog ("Current Voice ComboBox.ItemIndex = "
& Str(ComboBoxVoices.ListIndex)) WriteLog (vbTab & "Name: " &
SOTokenVoice.GetAttribute("Name")) WriteLog (vbTab & "Vendor: " &
SOTokenVoice.GetAttribute("Vendor")) WriteLog (vbTab & "Age: " &
SOTokenVoice.GetAttribute("Age")) WriteLog (vbTab & "Gender: " &
SOTokenVoice.GetAttribute("Gender")) WriteLog (vbTab & "Language: " +
SOTokenVoice.GetAttribute("Language")) WriteLog (vbTab + "Reg key: " & SOTokenVoice.Id) End
Sub '***************************************************************************** '
ComboBoxWaveFormats_Click -
Change the wave format '***************************************************************************** Private
Sub ComboBoxWaveFormats_Click() cmdButtonStop_Click Call ComboBoxWaveDevice_Click End
Sub '***************************************************************************** '
SliderSpeechRate_Click - Change the rate of speech '***************************************************************************** Private
Sub SliderSpeechRate_Click() spVoice1.Rate = SliderSpeechRate.Value LabelRatePos.Caption = Str(SliderSpeechRate.Value) End
Sub '***************************************************************************** '
SliderVolume_Click - Change the speech volume '***************************************************************************** Private
Sub SliderVolume_Click() spVoice1.Volume = SliderVolume.Value LabelVolumePos.Caption = Str(SliderVolume.Value) End
Sub '***************************************************************************** '
cmdButtonDial_Click - Dial an outgoing call using etLine '***************************************************************************** Private
Sub cmdButtonDial_Click() etLine1.CallHandle = 0 etLine1.CallPhoneNumber = TextPhoneNumber.Text WriteLog ("Dialing [" & TextPhoneNumber.Text
& "]") If etLine1.CallDial Then cmdButtonDial.Enabled = False cmdButtonHangup.Enabled = True Else WriteLog (vbTab & "Error =
" & etLine1.ErrorText) etLine1.CallHangup End If End
Sub '***************************************************************************** '
cmdButtonHangup_Click - Hangup an active call using etLine '***************************************************************************** Private
Sub cmdButtonHangup_Click() WriteLog ("Hangup") If (etLine1.CallHandle <> 0) And (etLine1.CallState
<> LINECALLSTATE_IDLE) Then cmdButtonStop_Click ' make sure to stop
speech if playing If etLine1.CallHangup Then
' if hangup returned true then... cmdButtonHangup.Enabled =
False Else WriteLog (vbTab &
"Error = " & etLine1.ErrorText) End If Else WriteLog ("Error Hanging Up " &
etLine1.ErrorText) End If End
Sub '************************************************ '
cmdButtonSpeak_Click - Play speech '************************************************ Private
Sub cmdButtonSpeak_Click() On
Error GoTo ErrHandler If Not bBeenPaused Then spVoice1.Speak
TextBoxTextToSpeak, iSpeechFlags Else spVoice1.Resume bBeenPaused = False cmdButtonPause.Picture =
cmdButtonPause.DisabledPicture WriteLog ("Speech
Resumed") End If Exit Sub ErrHandler: WriteLog ("Set audio
output error: " & Err.Description) End
Sub '***************************************************************************** '
cmdButonPause_Click - Pause the speech stream '***************************************************************************** Private
Sub cmdButtonPause_Click() WriteLog
("Pause pressed") If bBeenPaused Then spVoice1.Resume bBeenPaused = False cmdButtonPause.Picture =
cmdButtonPause.DisabledPicture WriteLog ("Speech
Resumed") Else spVoice1.Pause bBeenPaused = True cmdButtonPause.Picture =
cmdButtonPause.DownPicture WriteLog ("Speech
Paused") End If End
Sub '***************************************************************************** '
cmdButtonStop_Click - Stop the speech stream '***************************************************************************** Private
Sub cmdButtonStop_Click() On
Error GoTo ErrHandler WriteLog ("stop pressed") If spVoice1.Status.RunningState = SRSEIsSpeaking
Then WriteLog ("Running
State = 2 (SRSEIsSpeaking)") spVoice1.Speak
vbNullString, SVSFPurgeBeforeSpeak ' SpVoice1.Skip
"Sentence", reallybignumber ' alternate method Else WriteLog
("Running State = " & Str(spVoice1.Status.RunningState)) End If Exit Sub
ErrHandler: WriteLog ("Speak Error: " &
Err.Description) End
Sub '***************************************************************************** '
cmdButtonAnswer - Answer an incoming call using etLine '***************************************************************************** Private
Sub cmdButtonAnswer_Click() If etLine1.CallAnswer Then WriteLog ("etLine1.CallAnswer = True") Else WriteLog (vbTab & "Error Answering =
" & etLine1.ErrorText) End If End Sub '************************************************************************ '
cmdButtonLineConfig_Click - Display the device configuration screen for ' the TAPI hardware. This
is tied to the hardware manufacturer's ' Terminal Service Provider
or driver, also known as a TSP '************************************************************************ Private
Sub cmdButtonLineConfig_Click() etLine1.DeviceConfigure End
Sub
'
************************************************************************ '
cmdButtonTeleScope_Click - Enable TeleScope Tool ' TeleScope is an amazing
prototying, testing, debugging, and diagnostic tool ' Click the TeleScope
button and watch what happens in it's logs.
Place and receive ' calls and a LOT more.
See the help file section "Using TeleScope" '
************************************************************************ Private
Sub cmdButtonTeleScope_Click() etLine1.TeleScopeVisible = True etPlay1.TeleScopeVisible = True etRecord1.TeleScopeVisible = True WriteLog ("TeleScopes set to
'visible'") End
Sub
'
************************************************************************ '
cmdButtonClearLog_Click - Clear the call status log window '
************************************************************************ Private
Sub cmdButtonClearLog_Click() TextCallProgress.Text = Empty End
Sub '
************************************************************************ '
cmdButtonInfo_Click - Display about box '
************************************************************************ Private
Sub cmdButtonInfo_Click() MsgBox ("etTextToSpeech Sample Program"
& vbCrLf & vbCrLf & " Copyright(c) 2003 ExceleTel
Inc." _ & vbCrLf & vbCrLf &
"
www.exceletel.com") End Sub '***************************************************************************** '
etLine1_OnOffering - An incoming call is being "offered" '***************************************************************************** Private
Sub etLine1_OnOffering(ByVal CallHandle As Long) etLine1.CallHandle = CallHandle WriteLog ("OnOffering") cmdButtonAnswer.Enabled = True End
Sub
'***************************************************************************** '
etLine1_OnProceeding - the OnProceeding event has fired '
NOTE: Only available on TeleTools Standard Edition and above '***************************************************************************** Private
Sub etLine1_OnProceeding(ByVal CallHandle As Long) WriteLog ("etLine1.OnProceeding") End
Sub '***************************************************************************** '
etLine1_OnCallBegin - the OnCallBegin event has fired '***************************************************************************** Private
Sub etLine1_OnCallBegin(ByVal CallHandle As Long) WriteLog ("etLine1.OnCallBegin") cmdButtonHangup.Enabled = True End
Sub '***************************************************************************** '
etLine1_OnDialtone - the OnDialtone event has fired '***************************************************************************** Private
Sub etLine1_OnDialtone(ByVal CallHandle As Long) WriteLog ("etLine1.OnDialtone") End
Sub '***************************************************************************** '
etLine1_OnDialing - etLine is dialing a call '***************************************************************************** Private
Sub etLine1_OnDialing(ByVal CallHandle As Long) WriteLog ("etLine1.OnDialing") End
Sub '***************************************************************************** '
etLine1_OnBusy - Busy signal was detected '***************************************************************************** Private
Sub etLine1_OnBusy(ByVal CallHandle As Long) etLine1.CallHandle = CallHandle WriteLog ("etLine1.OnBusy") cmdButtonHangup_Click
' hangup on a busy signal End
Sub '***************************************************************************** '
etLine1_OnRing - The incoming
etLin1 OnRing event has fired, someone is calling '***************************************************************************** Private
Sub etLine1_OnRing(ByVal Count As Long, ByVal RingMode As Long) WriteLog ("etLine1.OnRing [" &
Str(Count) & ", " & Str(RingMode) + "]") End
Sub '***************************************************************************** '
etLine1_OnRingBack - The etLine OnRingBack event has fired, your call is
ringing '***************************************************************************** Private
Sub etLine1_OnRingBack(ByVal CallHandle As Long) WriteLog ("etLine1.OnRingBack") End
Sub '***************************************************************************** '
etLine1_OnCallerID - the OnCallerID event has fired ' You would use the
etLine.Call.CallerID.MaskNumber here to format the ' number based on if the CallOrigin was
Internal or External and other ' factors.
Use TeleScope and the Help File to learn more. '***************************************************************************** Private
Sub etLine1_OnCallerID(ByVal CallHandle As Long) WriteLog ("etLine1.OnCallerID") WriteLog (vbTab & "CallerIDName = "
& etLine1.CallCallerIDName) WriteLog (vbTab & "CallerIDNumber =
" & etLine1.CallCallerIDNumber) End
Sub '***************************************************************************** '
etLine1_OnCalledID - the OnCalledID event has fired ' NOTE: Only available on TeleTools Standard Edition and
above '***************************************************************************** Private
Sub etLine1_OnCalledID(ByVal CallHandle As Long) etLine1.CallHandle = CallHandle WriteLog ("etLine1.OnCalledID") WriteLog (vbTab & "CalledIDName = " &
etLine1.CallCalledIDName) WriteLog (vbTab & "CalledID.Number = " &
etLine1.CallCalledIDNumber) End
Sub '***************************************************************************** '
etLine1_OnConnectedID - the OnConnectedID event has fired ' NOTE: Only available on TeleTools Professional Edition
and above '***************************************************************************** Private
Sub etLine1_OnConnectedID(ByVal CallHandle As Long) WriteLog ("etLine1.OnConnectedID") WriteLog (vbTab & "ConnectedID.Name = " &
etLine1.CallConnectedIDName) WriteLog (vbTab & "ConnectedID.Number = " &
etLine1.CallConnectedIDNumber) End
Sub '***************************************************************************** '
etLine1_OnDigitReceived - a DTMF digit has been detected ' NOTE - Only available on TeleTools Standard Edition and
above '***************************************************************************** Private
Sub etLine1_OnDigitReceived(ByVal CallHandle As Long, ByVal Digit As
Integer, ByVal Tag As Long) WriteLog ("etLine1.OnDigitReceived [" &
Chr(Digit) & "]") With spVoice1 Select Case Chr(Digit) Case ("1") .Speak "you pressed
one", iSpeechFlags Case ("2") .Speak "you pressed
two", iSpeechFlags Case ("3") .Speak "you pressed
three", iSpeechFlags Case ("4") .Speak "you pressed
four", iSpeechFlags Case ("5") .Speak "you pressed
five", iSpeechFlags Case ("6") spVoice1.Speak "you
pressed six", iSpeechFlags Case ("7") .Speak "you pressed
seven", iSpeechFlags Case ("8") .Speak "you pressed
eight", iSpeechFlags Case ("9") .Speak "you pressed
nine", iSpeechFlags Case ("0") .Speak "you pressed
zero", iSpeechFlags Case ("*") .Speak "you pressed
star", iSpeechFlags Case ("#") .Speak "you pressed
pound", iSpeechFlags Case Else .Speak "I did not
recognize that selection", iSpeechFlags End Select End With End
Sub '***************************************************************************** '
etLine1_OnSpecialInfo - A Special Information Tone (SIT) was detected ' NOTE: Only available on TeleTools Standard Edition and
above '***************************************************************************** Private
Sub etLine1_OnSpecialInfo(ByVal CallHandle As Long) etLine1.CallHandle = CallHandle WriteLog ("etLine1.OnSpecialInfo") WriteLog (vbTab & "etLine1.CallSpecialInfo = "
& _ etLine1.StringLINESPECIALINFO(etLine1.CallSpecialInfo)) End
Sub '***************************************************************************** '
etLine1_OnConnected - The call is connected ' NOTE: Modems report the connected state immediately
after dialing the phone ' Number on outgoing
calls. You may not really be connected! '***************************************************************************** Private
Sub etLine1_OnConnected(ByVal CallHandle As Long) WriteLog
("etLine1.OnConnected") cmdButtonHangup.Enabled
= True cmdButtonAnswer.Enabled
= False cmdButtonSpeak.Enabled
= True If (InStr(1, etLine1.TAPITSP, "Modem",
1) > 0) Then If (Not
etLine1.PrivilegeNone) Then '
Using a voice modem etLine1.CallMonitorDigitsActive
= True End If Else If
(etLine1.AddressCapabilitiesCallFeatures And LINECALLFEATURE_MONITORDIGITS)
<> 0 Then etLine1.CallMonitorDigitsActive
= True End If End If spVoice1.Speak "Welcome to the ExceleTel e t Text To
Speech sample program. Please press a D T M F digit.", iSpeechFlags End
Sub '***************************************************************************** '
etLine1_OnDisconnected - The remote party has hung up the phone and
disconnected the call ' NOTE: Many modems do not report the remote party
disconnect! '***************************************************************************** Private
Sub etLine1_OnDisconnected(ByVal CallHandle As Long) WriteLog ("etLine1.OnDisconnected") WriteLog (vbTab & "Call.DisconnectMode = "
& _
etLine1.StringLINEDISCONNECTMODE(etLine1.CallDisconnectMode)) cmdButtonHangup_Click End
Sub '***************************************************************************** '
etLine1_OnIdle - The call is in the idle state '***************************************************************************** Private
Sub etLine1_OnIdle(ByVal CallHandle As Long) WriteLog ("etLine1.OnIdle") cmdButtonHangup.Enabled = False cmdButtonDial.Enabled = True End
Sub '***************************************************************************** '
etLine1_OnCallEnd - The etLine CallEnd event lets you know the call is
over '***************************************************************************** Private
Sub etLine1_OnCallEnd(ByVal CallHandle As Long) WriteLog ("etLine1.OnCallEnd") End
Sub '***************************************************************************** '
etLine1_OnError - etLine has generated and error ' You can process your own errors in your routines or use
the etLineOnError event ' to process them for you '***************************************************************************** Private
Sub etLine1_OnError() WriteLog ("etLine1.OnError") WriteLog (vbTab & "etLine1.Error = " &
etLine1.ErrorText) End
Sub '***************************************************************************** '
spVoice1_StartStream - The speech stream has started playing '***************************************************************************** Private
Sub spVoice1_StartStream(ByVal StreamNumber As Long, ByVal StreamPosition
As Variant) WriteLog ("OnStartStream") WriteLog (vbTab & "StreamNumber: "
& Str(StreamNumber)) WriteLog (vbTab & "StreamPosition:
" & Str(StreamPosition)) cmdButtonSpeak.Picture =
cmdButtonSpeak.DownPicture End
Sub '***************************************************************************** '
spVoice1_EndStream - The speech stream has finished playing '***************************************************************************** Private
Sub spVoice1_EndStream(ByVal StreamNumber As Long, ByVal StreamPosition As
Variant) WriteLog ("OnEndStream") WriteLog (vbTab & "StreamNumber: "
& Str(StreamNumber)) WriteLog (vbTab & "StreamPosition:
" & Str(StreamPosition)) cmdButtonSpeak.Picture =
cmdButtonSpeak.DisabledPicture cmdButtonPause.Picture =
cmdButtonPause.DisabledPicture End
Sub '***************************************************************************** '
spVoice1_Sentence - speaking a new sentence '***************************************************************************** Private
Sub spVoice1_Sentence(ByVal StreamNumber As Long, ByVal StreamPosition As
Variant, ByVal CharacterPosition As Long, ByVal Length As Long) WriteLog ("OnSentence") WriteLog (vbTab
& "StreamNumber: " & Str(StreamNumber)) WriteLog (vbTab & "StreamPosition:
" & Str(StreamPosition)) End
Sub '***************************************************************************** '
spVoice1_Word - event fired, new word '***************************************************************************** Private
Sub spVoice1_Word(ByVal StreamNumber As Long, ByVal StreamPosition As
Variant, ByVal CharacterPosition As Long, ByVal Length As Long) ' NOTE: We wanted to show you this event, but it is commented
out in ' this sample since it fires on every spoken word, it would
clutter the log ' WriteLog ("OnWord") End
Sub '***************************************************************************** '
spVoice1_VoiceChange - The speaking voice has changed '***************************************************************************** Private
Sub spVoice1_VoiceChange(ByVal StreamNumber As Long, ByVal StreamPosition
As Variant, ByVal VoiceObjectToken As SpeechLib.ISpeechObjectToken) WriteLog ("OnVoiceChange, " &
ComboBoxVoices.Text) End
Sub '***************************************************************************** '
spVoice1_AudioLevel - The audio level (volume) has changed '***************************************************************************** Private
Sub spVoice1_AudioLevel(ByVal StreamNumber As Long, ByVal StreamPosition
As Variant, ByVal AudioLevel As Long) ' NOTE: We wanted to show you this event, but it is
commented out in ' this sample since it fires so often, it would clutter
the log ' WriteLog ("OnAudoLevel") End
Sub '************************************************ '
WriteLog add log lines function '************************************************ Function
WriteLog(logtext As String) As String TextCallProgress.Text = TextCallProgress.Text
& logtext & vbCrLf TextCallProgress.SelStart =
Len(TextCallProgress.Text) End
Function '***************************************************************************** '
Forem_Unload - Unload the form and clear release all the objects '***************************************************************************** Private
Sub Form_Unload(Cancel As Integer) cmdButtonStop_Click cmdButtonHangup_Click If etPlay1.DeviceActive Then etPlay1.DeviceActive =
False If etPlay1.DeviceActive
Then WriteLog
(vbTab & "Error = " & etPlay1.ErrorText) End If End If If etRecord1.DeviceActive Then etRecord1.DeviceActive =
False If etRecord1.DeviceActive
Then WriteLog
(vbTab & "Error = " & etRecord1.ErrorText) End If End If etLine1.DeviceActive = False Set spVoice1.AudioOutput = Nothing ' reset audio
out to default Set spVoice1 = Nothing Set MMSysAudioOut1 = Nothing End
Sub |